10
script_name = File.basename($0)
14
:statefile => "/var/puppet/state/state.yaml",
15
:process => "puppetd",
19
o = OptionParser.new do |o|
20
o.set_summary_indent(' ')
21
o.banner = "Usage: #{script_name} [OPTIONS]"
22
o.define_head "The check_puppet Nagios plug-in checks that specified " +
10
script_name = File.basename($0)
14
:statefile => "/var/puppet/state/state.yaml",
15
:process => "puppetd",
19
o = OptionParser.new do |o|
20
o.set_summary_indent(' ')
21
o.banner = "Usage: #{script_name} [OPTIONS]"
22
o.define_head "The check_puppet Nagios plug-in checks that specified " +
23
23
"Puppet process is running and the state file is no " +
24
24
"older than specified interval."
26
o.separator "Mandatory arguments to long options are mandatory for " +
26
o.separator "Mandatory arguments to long options are mandatory for " +
27
27
"short options too."
29
o.on("-s", "--statefile=statefile", String, "The state file",
29
o.on("-s", "--statefile=statefile", String, "The state file",
30
30
"Default: #{OPTIONS[:statefile]}") { |OPTIONS[:statefile]| }
31
o.on("-p", "--process=processname", String, "The process to check",
31
o.on("-p", "--process=processname", String, "The process to check",
32
32
"Default: #{OPTIONS[:process]}") { |OPTIONS[:process]| }
33
o.on("-i", "--interval=value", Integer,
33
o.on("-i", "--interval=value", Integer,
34
34
"Default: #{OPTIONS[:interval]} minutes") { |OPTIONS[:interval]| }
37
o.on_tail("-h", "--help", "Show this help message.") do
47
unless ProcTable.ps.find { |p| p.name == OPTIONS[:process]}
59
intv = OPTIONS[:interval] * 60
63
@modt = File.mtime("#{OPTIONS[:statefile]}")
68
diff = (curt - @modt).to_i
82
state = "state file status okay updated on " + @modt.strftime("%m/%d/%Y at %H:%M:%S")
84
state = "state fille is not up to date and is older than #{OPTIONS[:interval]} minutes"
86
state = "state file status unknown"
91
process = "process #{OPTIONS[:process]} is running"
93
process = "process #{OPTIONS[:process]} is not running"
108
puts "PUPPET " + status + ": " + process + ", " + state
37
o.on_tail("-h", "--help", "Show this help message.") do
47
unless ProcTable.ps.find { |p| p.name == OPTIONS[:process]}
59
intv = OPTIONS[:interval] * 60
63
@modt = File.mtime("#{OPTIONS[:statefile]}")
68
diff = (curt - @modt).to_i
82
state = "state file status okay updated on " + @modt.strftime("%m/%d/%Y at %H:%M:%S")
84
state = "state fille is not up to date and is older than #{OPTIONS[:interval]} minutes"
86
state = "state file status unknown"
91
process = "process #{OPTIONS[:process]} is running"
93
process = "process #{OPTIONS[:process]} is not running"
108
puts "PUPPET " + status + ": " + process + ", " + state
113
113
cp = CheckPuppet.new