Class: Bipbip::Plugin::Memcached

Inherits:
Bipbip::Plugin show all
Defined in:
lib/bipbip/plugin/memcached.rb

Instance Attribute Summary

Attributes inherited from Bipbip::Plugin

#config, #metric_group, #name, #pid

Instance Method Summary collapse

Methods inherited from Bipbip::Plugin

factory, #frequency, #initialize, #interrupt, #interrupted?, #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_schemaObject



9
10
11
12
13
14
15
16
# File 'lib/bipbip/plugin/memcached.rb', line 9

def metrics_schema
  [
      {:name => 'cmd_get', :type => 'counter'},
      {:name => 'cmd_set', :type => 'counter'},
      {:name => 'get_misses', :type => 'counter'},
      {:name => 'bytes', :type => 'gauge', :unit => 'b'},
  ]
end

#monitorObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bipbip/plugin/memcached.rb', line 18

def monitor
  memcached = MemcachedClient.new(config['hostname'].to_s + ':' + config['port'].to_s)
  stats = memcached.stats
  memcached.quit

  data = {}
  metrics_names.each do |key|
    data[key] = stats[key.to_sym].shift.to_i
  end
  data
end