class Nagios::Plugin
Constants
- EXIT_CODE
- VERSION
Public Class Methods
run!(*args)
click to toggle source
# File lib/nagios/plugin.rb, line 11 def self.run!(*args) plugin = new(*args) plugin.check if plugin.respond_to?(:check) puts plugin.output exit EXIT_CODE[plugin.status] rescue => e puts "PLUGIN UNKNOWN: #{e.message}\n\n" << e.backtrace.join("\n") exit EXIT_CODE[:unknown] end
Public Instance Methods
name()
click to toggle source
# File lib/nagios/plugin.rb, line 34 def name self.class.name.split('::').last.upcase end
output()
click to toggle source
# File lib/nagios/plugin.rb, line 21 def output s = "#{name.upcase} #{status.upcase}" s << ": #{message}" if ( respond_to?(:message) && !message.to_s.empty? ) s end
status()
click to toggle source
# File lib/nagios/plugin.rb, line 27 def status return :critical if critical? return :warning if warning? return :ok if ok? :unknown end
to_s()
click to toggle source
# File lib/nagios/plugin.rb, line 38 def to_s output end