Skip to content

Instantly share code, notes, and snippets.

@lchi
Created May 15, 2014 21:43
Show Gist options
  • Save lchi/0504d8daba72c245754b to your computer and use it in GitHub Desktop.
Save lchi/0504d8daba72c245754b to your computer and use it in GitHub Desktop.
memcache stats
#!/usr/bin/env ruby
stats_prev = {}
loop do
stats = {}
stats_output = `echo 'stats' | nc localhost 11211 | sed 's/STAT //g' | grep -v END`
stats_output.split("\n").each do |line|
k, v = line.split(" ")
stats[k] = v.to_i
end
stats_prev.each_pair do |k,v|
puts "#{k}: #{stats[k] - v}/s"
end
stats_prev = stats
puts ""
sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment