Skip to content

Instantly share code, notes, and snippets.

@bryanl
Created August 24, 2010 15:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bryanl/547726 to your computer and use it in GitHub Desktop.
Save bryanl/547726 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'net/telnet'
require 'memcache'
require 'action_view'
include ActionView::Helpers::TextHelper
cache = MemCache.new 'localhost:11211'
raw = Net::Telnet.new("Host" => "localhost", "Port" => 11211, "Prompt" => /END/)
items = raw.cmd("stats items")
keys = items.split(/\n/).
grep(/items:\w+:number/).
map{|x| x.match(/items:(\w+):number/)[1]}.
map{|x| raw.cmd("stats cachedump #{x} 100")}.
map{|x| x.split(/\s+/)[1]}
max_key_length = 0
keys.each{|key| max_key_length = key.size if key.size > max_key_length }
keys.each do |key|
data = truncate(cache.get(key).to_s.gsub(/\r\n/,'\r\n'), :length => 50)
printf("%30s | %s\n", key, data)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment