Class: NagiosPlugin::Plugin
- Inherits:
-
Object
- Object
- NagiosPlugin::Plugin
- Defined in:
- lib/nagiosplugin/plugin.rb
Constant Summary collapse
- NAGIOS_PLUGIN_EXIT_CODES =
{ :unknown => 3, :critical => 2, :warning => 1, :ok => 0 }
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.check(*args) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/nagiosplugin/plugin.rb', line 11 def check(*args) plugin = new(*args) puts plugin.nagios_plugin_output exit plugin.nagios_plugin_exit_code rescue => e pretty_error = ([e.to_s, nil] + e.backtrace).join("\n") puts "PLUGIN UNKNOWN: #{pretty_error}" exit NAGIOS_PLUGIN_EXIT_CODES[:unknown] end |
Instance Method Details
#nagios_plugin_exit_code ⇒ Object
22 23 24 |
# File 'lib/nagiosplugin/plugin.rb', line 22 def nagios_plugin_exit_code NAGIOS_PLUGIN_EXIT_CODES[nagios_plugin_status] end |
#nagios_plugin_output ⇒ Object
26 27 28 29 30 31 |
# File 'lib/nagiosplugin/plugin.rb', line 26 def nagios_plugin_output output = [nagios_plugin_service] << ' ' output << nagios_plugin_status.to_s.upcase output << ': ' + if ( respond_to?(:message) && !.empty? ) output.join end |