Skip to content

Instantly share code, notes, and snippets.

@stonegao
Forked from jfqd/memcached_munin_plugin.rb
Created August 9, 2010 14:23
Show Gist options
  • Select an option

  • Save stonegao/515473 to your computer and use it in GitHub Desktop.

Select an option

Save stonegao/515473 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# memcached munin plugin
require 'rubygems'
require 'memcache'
if ENV['HOST'].nil? or ENV['PORT'].nil?
puts "Define a HOST and PORT!"
Kernel.exit(1)
end
if ARGV.first == "config"
puts "graph_title #{server_str} - items"
puts 'graph_category Memcached'
puts 'graph_vlabel Items'
puts 'curr_items.label Current items'
puts 'evictions.label Items ousted'
else
mem = Memcache::Server.new(:host => ENV['HOST'], :port => ENV['PORT'])
stats_hash = mem.stats
puts "curr_items.value #{stats_hash['curr_items']}"
puts "evictions.value #{stats_hash['evictions']}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment