Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 93 lines (69 sloc) 2.668 kB
c8e5937 @ripienaar Update README
authored
1 What?
2 =====
3 Have you ever had to disable alerts, retry a check
4 or acknowledge outages on a large amount of service
5 with Nagios and hated the web UI for it?
5091eed @ripienaar add a readme
authored
6
c8e5937 @ripienaar Update README
authored
7 This is a CLI tool and Ruby library that parses your
8 status log file and let you query it for information
9 or create external commands to be piped into the nagios
10 command file.
5091eed @ripienaar add a readme
authored
11
f73d9ff @ripienaar mention rubygems
authored
12 You can get this software here on GitHub or via RubyGems
13 as *ruby-nagios*
14
c8e5937 @ripienaar Update README
authored
15 Using on the CLI?
16 =================
17 Find out what services match a regular expression:
18
19 nagsrv --list-services --with-service /puppet/
20 puppet-freshness
21 puppetd
22 puppetmaster
23
24 Find hosts with the service /puppet/:
25
26 nagsrv --list-hosts --with-service /puppet/
27 dev1.your.net
28 dev2.your.net
29 .
30 .
31
32 Disable notifications for them all on all hosts:
33
34 nagsrv.rb --disable-notify --with-service /puppet/
35 [1263129006] DISABLE_SVC_NOTIFICATIONS;dev1.your.net;puppet-freshness
36 [1263129006] DISABLE_SVC_NOTIFICATIONS;dev1.your.net;puppetd
37 [1263129006] DISABLE_SVC_NOTIFICATIONS;dev1.your.net;puppet-freshness
38 .
39 .
40 .
41
42 Only do it for hosts matching /dev2/:
43
44 nagsrv.rb --disable-notify --with-service /puppet/ --for-host /dev2/
45 [1263129038] DISABLE_SVC_NOTIFICATIONS;dev2.your.net;puppet-freshness
46 [1263129038] DISABLE_SVC_NOTIFICATIONS;dev2.your.net;puppetd
47
48 You can do ack's, force checks etc, see the help or
49 comments in the nagsrv.rb script. To actually get
50 nagios to do these actions just redirect the output
51 from these commands to the Nagios CMD file. On my
52 machine that is /var/log/nagios/rw/nagios.cmd.
53
54 Using from Ruby?
55 ================
56
57 You can also do the same from within Ruby easily,
58 the library lets you search host by any property
59 on a service, here we'll find all hosts with
60 service /puppet/ on host /dev2/:
61
62 require 'rubygems'
63 require 'nagios/status'
64 nagios = Nagios::Status.new
65 nagios.parsestatus("status.log")
66
2e1f2ee @ripienaar fix line lengths
authored
67 options = {:forhost => "/dev2/", :action => "${host}",
68 :withservice => "/puppet/"}
c8e5937 @ripienaar Update README
authored
69 services = nagios.find_services(options)
70
71 puts services.join("\n")
72
73 This will in this case just print:
74
75 dev2.your.net
76
77 If you didn't specify the :action string it would
78 just return an array of services found. The :action
79 string is a template that lets you return the matches
80 in any format you like, here's a template to Acknowledge
81 services:
82
2e1f2ee @ripienaar fix line lengths
authored
83 "[${tstamp}] ACKNOWLEDGE_SVC_PROBLEM;;${host};${service};1 \
84 ;0;1;#{ENV['USER']};Acknowledged from CLI"
c8e5937 @ripienaar Update README
authored
85
86 The only variables it supports now is ${host}, ${service}
87 and ${tstamp} we can easily add more if needed.
88
89 Contact?
90 ========
91
92 R.I.Pienaar / rip@devco.net / @ripienaar / http://devco.net/
Something went wrong with that request. Please try again.