Class: Nagios::Check
- Inherits:
-
Object
- Object
- Nagios::Check
- Defined in:
- lib/nagios_helper/check.rb
Direct Known Subclasses
Constant Summary collapse
- TYPES =
%w{ok crit other warn}
Class Method Summary collapse
-
.check(params = {}) ⇒ Object
synchrony check, for manually calls.
- .default_error(mes) ⇒ Object
Instance Method Summary collapse
-
#initialize(params, &callback) ⇒ Check
constructor
A new instance of Check.
- #result ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(params, &callback) ⇒ Check
Returns a new instance of Check.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nagios_helper/check.rb', line 5 def initialize(params, &callback) @params = params.with_indifferent_access @callback = callback @started_at = Time.now @tag = "#{self.class.name}/#{params.inspect}" logger.info "=> #{@tag}" @ok = [] @crit = [] @warn = [] @other = [] end |
Class Method Details
.check(params = {}) ⇒ Object
synchrony check, for manually calls
41 42 43 44 45 46 47 48 49 |
# File 'lib/nagios_helper/check.rb', line 41 def self.check(params = {}) result = nil inst = self.new(params) do |res| result = res end inst.run end |
Instance Method Details
#result ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nagios_helper/check.rb', line 19 def result errors = [@crit, @warn, @other].flatten * '; ' if @crit.present? [Nagios::CRIT, "CRIT: " + errors] elsif @warn.present? [Nagios::WARN, "WARN: " + errors] elsif @other.present? [Nagios::OTHER, errors] else [Nagios::OK, "OK: " + @ok * '; '] end end |
#run ⇒ Object
33 34 35 36 37 38 |
# File 'lib/nagios_helper/check.rb', line 33 def run safe do execute send_result end end |