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, #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_schemaObject



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

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

#monitorObject



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

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