Class: Nagios::Plugin
- Inherits:
-
Object
- Object
- Nagios::Plugin
- Defined in:
- lib/nagios/plugin.rb
Class Method Summary collapse
-
.run! ⇒ Object
Syntactic sugar for creating a new instance automagically.
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
Class Method Details
.run! ⇒ Object
Syntactic sugar for creating a new instance automagically
6 7 8 |
# File 'lib/nagios/plugin.rb', line 6 def run! new.run! end |
Instance Method Details
#run! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nagios/plugin.rb', line 16 def run! @config.parse! begin @value = measure if critical(@value) exit_with :critical, get_msg(:critical, @value) elsif warning(@value) exit_with :warning, get_msg(:warning, @value) else exit_with :ok, get_msg(:ok, @value) end rescue => e exit_unknown e end end |
#status ⇒ Object
46 47 48 49 |
# File 'lib/nagios/plugin.rb', line 46 def status @status_used = true @status end |
#threshold(level) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/nagios/plugin.rb', line 32 def threshold(level) if level == :warning @config[:warning] || -1 elsif level == :critical @config[:critical] || -1 else -1 end end |
#to_s(value) ⇒ Object
42 43 44 |
# File 'lib/nagios/plugin.rb', line 42 def to_s(value) "#{value}" end |