Sha256: 04f89ddf462f2789ead419148b324bb38a76cbcff9efb39e3ecb3ecb27dfb820
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
#!/usr/bin/env ruby # # memcached-graphite # # DESCRIPTION: # Push Memcached stats into graphite # # OUTPUT: # metric data # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: sensu-plugin # gem: memcached # gem: socket # # USAGE: # #YELLOW # # NOTES: # #YELLOW # HitRatio percent and per second calculations # # LICENSE: # Copyright 2012 Pete Shima <me@peteshima.com> # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/metric/cli' require 'dalli' require 'socket' class MemcachedGraphite < Sensu::Plugin::Metric::CLI::Graphite option :host, short: '-h HOST', long: '--host HOST', description: 'Memcached Host to connect to', default: 'localhost' option :port, short: '-p PORT', long: '--port PORT', description: 'Memcached Port to connect to', proc: proc(&:to_i), default: 11_211 option :scheme, description: 'Metric naming scheme, text to prepend to metric', short: '-s SCHEME', long: '--scheme SCHEME', default: "#{::Socket.gethostname}.memcached" def run cache = Dalli::Client.new("#{config[:host]}:#{config[:port]}") # cache.stats returns a hash of server => stats. Since we only have one # server, we can just grab the first value and iterate over that. cache.stats.values.first.each do |k, v| output "#{config[:scheme]}.#{k}", v end ok end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
sensu-plugins-memcached-boutetnico-1.0.0 | bin/metrics-memcached-graphite.rb |
sensu-plugins-memcached-0.1.3 | bin/metrics-memcached-graphite.rb |