Module: NRPE::Check
- Defined in:
- lib/nrpe_check/check.rb
Instance Method Summary collapse
- #check ⇒ Object
- #exit_with_status(status, message = nil) ⇒ Object
- #set_default_status ⇒ Object
- #status(status, message = nil) ⇒ Object
Instance Method Details
#check ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/nrpe_check/check.rb', line 4 def check set_default_status yield if block_given? rescue Exception => exit_with_status :unknown, end |
#exit_with_status(status, message = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nrpe_check/check.rb', line 18 def exit_with_status status, = nil case status.downcase when :ok, :warning, :critical, :unknown STDOUT.puts "#{status.upcase}: " + if exit! eval ['NRPE', 'Status', status.upcase].join '::' else raise 'invalid NRPE::Check exit status' end end |
#set_default_status ⇒ Object
29 30 31 |
# File 'lib/nrpe_check/check.rb', line 29 def set_default_status status :unknown, "#{$0} failed to set an exit status" end |
#status(status, message = nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/nrpe_check/check.rb', line 12 def status status, = nil at_exit do exit_with_status status, end end |