Class: Bluepill::Gearman::SendGearman
- Inherits:
-
Trigger
- Object
- Trigger
- Bluepill::Gearman::SendGearman
- Defined in:
- lib/bluepill-gearman.rb
Instance Method Summary collapse
-
#initialize(process, options = {}) ⇒ SendGearman
constructor
A new instance of SendGearman.
-
#notify(transition) ⇒ Object
Called by bluepill when process states changes.
Constructor Details
#initialize(process, options = {}) ⇒ SendGearman
Returns a new instance of SendGearman.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bluepill-gearman.rb', line 28 def initialize(process, ={}) @default_args = { :gearman_job_server => ["#{.delete(:gearman_server)}:#{.delete(:gearman_port) || 4730}"], :host => .delete(:host) || `hostname -f`.chomp, :service => .delete(:service) || process.name, :queue => .delete(:queue) || 'check_results', :key => .delete(:key) || '', :encryption => .delete(:encryption) || false, :every => .delete(:every) || 1.minute } 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bluepill-gearman.rb', line 45 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_gearman(_args) end end |