8 script_name = File.basename($0)
12 :statefile => "/var/lib/puppet/state/state.yaml",
16 o = OptionParser.new do |o|
17 o.set_summary_indent(' ')
18 o.banner = "Usage: #{script_name} [OPTIONS]"
19 o.define_head "The check_puppet Nagios plug-in checks that the specified " +
20 "puppet state file is no older than specified interval."
22 o.separator "Mandatory arguments to long options are mandatory for " +
25 o.on("-s", "--statefile=statefile", String, "The state file",
26 "Default: #{OPTIONS[:statefile]}") { |OPTIONS[:statefile]| }
27 o.on("-i", "--interval=value", Integer,
28 "Default: #{OPTIONS[:interval]} minutes") { |OPTIONS[:interval]| }
31 o.on_tail("-h", "--help", "Show this help message.") do
43 intv = OPTIONS[:interval] * 60
48 @modt = File.mtime("#{OPTIONS[:statefile]}")
53 diff = (curt - @modt).to_i
56 @file = 0 if diff <= intv
64 state = "state file status okay updated on " + @modt.strftime("%m/%d/%Y at %H:%M:%S")
66 state = "state file is missing or older than #{OPTIONS[:interval]} minutes"
68 state = "state file status unknown"
83 puts "PUPPET " + status + ": " + state