Class: Bluepill::Nagios::Nsca
- Inherits:
-
Trigger
- Object
- Trigger
- Bluepill::Nagios::Nsca
- Defined in:
- lib/bluepill-nagios.rb
Instance Method Summary collapse
-
#initialize(process, options = {}) ⇒ Nsca
constructor
Called by bluepill when a “checks :nsca” is declared in pill file.
-
#notify(transition) ⇒ Object
Called by bluepill when process states changes.
Constructor Details
#initialize(process, options = {}) ⇒ Nsca
Called by bluepill when a “checks :nsca” is declared in pill file
15 16 17 18 19 20 21 22 23 |
# File 'lib/bluepill-nagios.rb', line 15 def initialize(process, ={}) @default_args = { :nscahost => .delete(:nscahost), :port => .delete(:port) || 5667, :hostname => .delete(:host) || `hostname -f`.chomp, :service => .delete(:service) || process.name } super end |
Instance Method Details
#notify(transition) ⇒ Object
Called by bluepill when process states changes. Notifies the nagios when:
-
the process goes to :unmonitored notifies warning
-
the process goes to :down notifies critical
-
the process goes to :up notifies ok
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bluepill-nagios.rb', line 29 def notify(transition) _return_code, _status = case transition.to_name when :down [2, "Bluepill reported process down at #{Time.now}"] when :unmonitored [1 , "Bluepill stopped monitoring at #{Time.now}"] when :up [0 , "Running"] else [nil, nil] end if _status and _return_code _args = @default_args.merge({:status => _status, :return_code => _return_code}) send_nsca(_args) end end |