Class: NagiosPlugin::Plugin
- Inherits:
-
Object
- Object
- NagiosPlugin::Plugin
- Defined in:
- lib/nagiosplugin/plugin.rb
Defined Under Namespace
Classes: StatusError
Class Method Summary collapse
-
.critical(message) ⇒ Object
Raise critical StatusError with message.
-
.ok(message) ⇒ Object
Raise ok StatusError with message.
-
.run(*args) ⇒ Object
Create new instance and run it.
-
.unknown(message) ⇒ Object
Raise unknown StatusError with message.
-
.warning(message) ⇒ Object
Raise warning StatusError with message.
Instance Method Summary collapse
-
#check ⇒ Object
Overwrite this check method and call a status method within.
-
#run ⇒ Object
Run check and return result in a nagios-compatible format.
Class Method Details
.critical(message) ⇒ Object
Raise critical StatusError with message
57 |
# File 'lib/nagiosplugin/plugin.rb', line 57 make :critical |
.ok(message) ⇒ Object
Raise ok StatusError with message
55 |
# File 'lib/nagiosplugin/plugin.rb', line 55 make :ok |
.run(*args) ⇒ Object
Create new instance and run it.
37 38 39 |
# File 'lib/nagiosplugin/plugin.rb', line 37 def run(*args) self.new(*args).run end |
.unknown(message) ⇒ Object
Raise unknown StatusError with message
58 |
# File 'lib/nagiosplugin/plugin.rb', line 58 make :unknown |
.warning(message) ⇒ Object
Raise warning StatusError with message
56 |
# File 'lib/nagiosplugin/plugin.rb', line 56 make :warning |
Instance Method Details
#check ⇒ Object
Overwrite this check method and call a status method within.
61 62 63 |
# File 'lib/nagiosplugin/plugin.rb', line 61 def check unknown 'please overwrite the method `check` in your class' end |
#run ⇒ Object
Run check and return result in a nagios-compatible format.
It will…
-
execute your check method
-
output the result in a nagios-compatible format (SERVICE STATUS: Message)
-
exit according to the status
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nagiosplugin/plugin.rb', line 71 def run check rescue StatusError => e rescue => e e = StatusError.new(:unknown, ([e.to_s, nil] + e.backtrace).join("\n")) else e = StatusError.new(:unknown, 'no status method was called') ensure puts [self.class.name.upcase, e.to_s].join(' ') exit e.to_i end |