nagiosharder 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/nagiosharder.rb +33 -5
- data/nagiosharder.gemspec +1 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "nagiosharder"
|
8
|
-
gem.version = "0.
|
8
|
+
gem.version = "0.2.0"
|
9
9
|
gem.summary = %Q{Nagios access at your ruby fingertips}
|
10
10
|
gem.description = %Q{Nagios access at your ruby fingertips}
|
11
11
|
gem.email = "josh@technicalpickles.com"
|
data/lib/nagiosharder.rb
CHANGED
@@ -293,13 +293,37 @@ class NagiosHarder
|
|
293
293
|
|
294
294
|
if columns[1]
|
295
295
|
service_links = columns[1].css('td a')
|
296
|
+
service_link, other_links = service_links[0], service_links[1..-1]
|
297
|
+
if service_links.size > 1
|
298
|
+
comments_link = other_links.detect do |link|
|
299
|
+
link.attribute('href').to_s =~ /#comments$/
|
300
|
+
end
|
301
|
+
comments_url = comments_link.attribute('href').to_s if comments_link
|
302
|
+
|
303
|
+
flapping = other_links.any? do |link|
|
304
|
+
link.css('img').attribute('src').to_s =~ /flapping\.gif/
|
305
|
+
end
|
306
|
+
|
307
|
+
acknowledged = other_links.any? do |link|
|
308
|
+
link.css('img').attribute('src').to_s =~ /ack\.gif/
|
309
|
+
end
|
310
|
+
|
311
|
+
extra_service_notes_link = other_links.detect do |link|
|
312
|
+
link.css('img').any? do |img|
|
313
|
+
img.attribute('src').to_s =~ /notes\.gif/
|
314
|
+
end
|
315
|
+
end
|
316
|
+
extra_service_notes_url = extra_service_notes_link.attribute('href').to_s if extra_service_notes_link
|
317
|
+
end
|
318
|
+
|
296
319
|
service = service_links[0].inner_html
|
297
|
-
acknowledged = service_links.size == 3 # acknowledged servies have a link to the service, link to comments, and a link to unacknowledge
|
298
320
|
end
|
299
321
|
|
300
322
|
status = columns[2].inner_html if columns[2]
|
301
|
-
last_check =
|
302
|
-
|
323
|
+
last_check = if columns[3]
|
324
|
+
datetime = DateTime.strptime(columns[3].inner_html, "%m-%d-%Y %H:%M:%S") rescue nil # nyoo
|
325
|
+
end
|
326
|
+
duration = columns[4].inner_html.squeeze(' ').gsub(/^ /, '') if columns[4]
|
303
327
|
started_at = if duration && match_data = duration.match(/^\s*(\d+)d\s+(\d+)h\s+(\d+)m\s+(\d+)s\s*$/)
|
304
328
|
(
|
305
329
|
match_data[1].to_i.days +
|
@@ -307,15 +331,16 @@ class NagiosHarder
|
|
307
331
|
match_data[3].to_i.minutes +
|
308
332
|
match_data[4].to_i.seconds
|
309
333
|
).ago
|
310
|
-
|
311
334
|
end
|
312
335
|
attempts = columns[5].inner_html if columns[5]
|
313
336
|
status_info = columns[6].inner_html.gsub(' ', '') if columns[6]
|
314
337
|
|
315
338
|
if host && service && status && last_check && duration && attempts && started_at && status_info
|
316
339
|
service_extinfo_url = "#{extinfo_url}?type=2&host=#{host}&service=#{CGI.escape(service)}"
|
340
|
+
host_extinfo_url = "#{extinfo_url}?type=1&host=#{host}"
|
317
341
|
|
318
342
|
status = Hashie::Mash.new :host => host,
|
343
|
+
:host_extinfo_url => host_extinfo_url,
|
319
344
|
:service => service,
|
320
345
|
:status => status,
|
321
346
|
:last_check => last_check,
|
@@ -324,7 +349,10 @@ class NagiosHarder
|
|
324
349
|
:started_at => started_at,
|
325
350
|
:extended_info => status_info,
|
326
351
|
:acknowledged => acknowledged,
|
327
|
-
:
|
352
|
+
:service_extinfo_url => service_extinfo_url,
|
353
|
+
:flapping => flapping,
|
354
|
+
:comments_url => comments_url,
|
355
|
+
:extra_service_notes_url => extra_service_notes_url
|
328
356
|
|
329
357
|
yield status
|
330
358
|
end
|
data/nagiosharder.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nagiosharder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Nichols
|