Class: Bipbip::Plugin::Gearman
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::Gearman
- Defined in:
- lib/bipbip/plugin/gearman.rb
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
#initialize, #interrupt, #interrupted?, #metric_identifier, #metrics_names, #name, #run
Methods included from InterruptibleSleep
#interrupt_sleep, #interruptible_sleep
Constructor Details
This class inherits a constructor from Bipbip::Plugin
Instance Method Details
#metrics_schema ⇒ Object
9 10 11 12 13 |
# File 'lib/bipbip/plugin/gearman.rb', line 9 def metrics_schema [ {:name => 'jobs_queued_total', :type => 'ce_gauge', :unit => 'Jobs'}, ] end |
#monitor(server) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bipbip/plugin/gearman.rb', line 15 def monitor(server) gearman = GearmanServer.new(server['hostname'] + ':' + server['port'].to_s) stats = gearman.status jobs_queued_total = 0 stats.each do |function_name, data| data.each do |queue, stats| jobs_queued_total += queue.to_i end end {:jobs_queued_total => jobs_queued_total} end |