Class: Nagios::Plugin
- Inherits:
-
Object
- Object
- Nagios::Plugin
- Defined in:
- lib/nagios/plugin.rb
Instance Method Summary collapse
-
#initialize ⇒ Plugin
constructor
A new instance of Plugin.
- #run! ⇒ Object
- #status ⇒ Object
- #threshold(level) ⇒ Object
- #to_s(value) ⇒ Object
Constructor Details
Instance Method Details
#run! ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nagios/plugin.rb', line 9 def run! @config.parse! begin @value = measure if critical(@value) exit_with :critical, @value elsif warning(@value) exit_with :warning, @value else exit_with :ok, @value end rescue => e exit_unknown e end end |
#status ⇒ Object
39 40 41 42 |
# File 'lib/nagios/plugin.rb', line 39 def status @status_used = true @status end |
#threshold(level) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/nagios/plugin.rb', line 25 def threshold(level) if level == :warning @config[:warning] || -1 elsif level == :critical @config[:critical] || -1 else -1 end end |
#to_s(value) ⇒ Object
35 36 37 |
# File 'lib/nagios/plugin.rb', line 35 def to_s(value) "#{value}" end |