lita-nagios 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c44656f16b7da317f21677ea42f7b8e60c77d6
4
- data.tar.gz: 4a39170f725faf85d8cd3400c8f5a2c7dd55ee3d
3
+ metadata.gz: aebcf98f262d143c01d14c6578dc817ac99b289a
4
+ data.tar.gz: 99449e4ffc1b4ce9b6410b0a437a206ab36e9f5a
5
5
  SHA512:
6
- metadata.gz: 9bcb83b3f12db66c0902748793df671583c16f7802e608ab145d4425fde3c2615210f29adb139c57714b42f46b407b85400c902117049d676d13957205b50773
7
- data.tar.gz: a039c8f62ddd61175db75d81380f0ccbf73434a2ec336214c6ae0438bea52d971fba6484eba07a92d9a2bcc0f69224f45cc8b1d6f872f5bce99d8a1d16c605d4
6
+ metadata.gz: c496d8326859e44b31ed05488497b39eaa2cd78d70251cea5680a9b61a4a156486112e493cdadc0241389f4c4d8f382b1b53cbda23d61bc70ffa1fab329b7613
7
+ data.tar.gz: b1d490206425af2b14f804853ae484db65589947d28f208a9fd78cc5ad91b5e68f8751383689020f9b939d8edd62e3de81b2c786380d2d42dc1aa2ebb8959702
@@ -3,9 +3,9 @@ define command {
3
3
  command_line /usr/bin/curl --request POST --connect-timeout 1 --max-time 2 $CONTACTADDRESS1$ \
4
4
  --data-urlencode "room=#chan" \
5
5
  --data-urlencode "type=host" \
6
- --data-urlencode "host="$HOSTNAME$" \
7
- --data-urlencode "output="$HOSTOUTPUT$" \
8
- --data-urlencode "state="$HOSTSTATE$" \
6
+ --data-urlencode "host=$HOSTNAME$" \
7
+ --data-urlencode "output=$HOSTOUTPUT$" \
8
+ --data-urlencode "state=$HOSTSTATE$" \
9
9
  --data-urlencode "notificationtype=$NOTIFICATIONTYPE$"
10
10
  }
11
11
 
@@ -23,7 +23,7 @@ define command {
23
23
 
24
24
  define contact{
25
25
  contact_name bot
26
- alias Lita IRC
26
+ alias Lita
27
27
  service_notification_period 24x7
28
28
  host_notification_period 24x7
29
29
  service_notification_options w,u,c,r
@@ -157,62 +157,41 @@ module Lita
157
157
  http.post "/nagios/notifications", :receive
158
158
 
159
159
  def receive(request, response)
160
- if request.params.has_key?("type")
161
- notif_type = request.params["type"].to_sym
162
- unless respond_to?(notif_type, true)
163
- raise "'#{notif_type}' is not supported by Nagios handler"
164
- end
165
- else
166
- raise "Notification type must be defined in Nagios command"
167
- end
160
+ params = request.params
168
161
 
169
- if request.params.has_key?("room")
170
- room = request.params["room"]
162
+ if params.has_key?("room")
163
+ room = params["room"]
171
164
  elsif config.default_room
172
165
  room = config.default_room
173
166
  else
174
167
  raise "Room must be defined. Either fix your command or specify a default room ('config.handlers.nagios.default_room')"
175
168
  end
176
169
 
177
- message = send(notif_type, request.params)
170
+ message = nil
171
+ case params["notificationtype"]
172
+ when "ACKNOWLEDGEMENT"
173
+ message = "[ACK] "
174
+ when "PROBLEM", "RECOVERY"
175
+ message = ""
176
+ else
177
+ # Don't process FLAPPING* and DOWNTIME* events for now
178
+ return
179
+ end
180
+
181
+ case params["type"]
182
+ when "service"
183
+ message += "#{params["host"]}:#{params["description"]} is #{params["state"]}: #{params["output"]}"
184
+ when "host"
185
+ message += "#{params["host"]} is #{params["state"]}: #{params["output"]}"
186
+ else
187
+ raise "Notification type must be defined in Nagios command ('host' or 'service')"
188
+ end
178
189
 
179
190
  target = Source.new(room: room)
180
191
  robot.send_message(target, "nagios: #{message}")
181
192
  rescue Exception => e
182
193
  Lita.logger.error(e)
183
194
  end
184
-
185
- private
186
-
187
- def host(params)
188
- case params["state"]
189
- when "UP"
190
- color = :light_green
191
- when "DOWN"
192
- color = :light_red
193
- when "UNREACHABLE"
194
- color = :orange
195
- end
196
- status = params["state"]
197
-
198
- message = "#{params["host"]} is #{status}: #{params["output"]}"
199
- end
200
-
201
- def service(params)
202
- case params["state"]
203
- when "OK"
204
- color = :light_green
205
- when "WARNING"
206
- color = :yellow
207
- when "CRITICAL"
208
- color = :light_red
209
- when "UNKNOWN"
210
- color = :orange
211
- end
212
- status = params["state"]
213
-
214
- message = "#{params["host"]}:#{params["description"]} is #{status}: #{params["output"]}"
215
- end
216
195
  end
217
196
 
218
197
  Lita.register_handler(Nagios)
data/lita-nagios.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-nagios"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.1.1"
4
4
  spec.authors = ["Jonathan Amiez"]
5
5
  spec.email = ["jonathan.amiez@gmail.com"]
6
6
  spec.description = "Nagios interaction with Lita"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-nagios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Amiez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita