Class: Bipbip::Plugin::Gearman
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::Gearman
- Defined in:
- lib/bipbip/plugin/gearman.rb
Instance Attribute Summary
Attributes inherited from Bipbip::Plugin
#config, #frequency, #metric_group, #name, #tags
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, factory_from_plugin, #initialize, #metrics_names, #run, #source_identifier
Methods included from InterruptibleSleep
#interrupt_sleep, #interruptible_sleep
Constructor Details
This class inherits a constructor from Bipbip::Plugin
Instance Method Details
#metrics_schema ⇒ Object
7 8 9 10 11 12 |
# File 'lib/bipbip/plugin/gearman.rb', line 7 def metrics_schema [ { name: 'jobs_queued_total', type: 'gauge', unit: 'Jobs' }, { name: 'jobs_active_total', type: 'gauge', unit: 'Jobs' } ] end |
#monitor ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bipbip/plugin/gearman.rb', line 14 def monitor gearman = GearmanServer.new(config['hostname'] + ':' + config['port'].to_s) stats = gearman.status jobs_queued_total = 0 jobs_active_total = 0 stats.each do |_function_name, data| jobs_queued_total += data[:queue].to_i jobs_active_total += data[:active].to_i end { jobs_queued_total: jobs_queued_total, jobs_active_total: jobs_active_total } end |