Skip to content

Instantly share code, notes, and snippets.

@kenn
Created August 25, 2011 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenn/1169808 to your computer and use it in GitHub Desktop.
Save kenn/1169808 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def report
output = `ktremotemgr report -host 127.0.0.1`
{}.tap{|h| output.split("\n").map{|i| i.split(': ') }.each{|i| h[i[0]] = i[1] } }
end
hash = report
last_get, last_set, last_remove = hash['cnt_get'].to_i, hash['cnt_set'].to_i, hash['cnt_remove'].to_i
puts "cnt_get\tcnt_set\tcnt_remove\ttotal"
loop do
sleep 1
hash = report
current_get, current_set, current_remove = hash['cnt_get'].to_i, hash['cnt_set'].to_i, hash['cnt_remove'].to_i
qps_get, qps_set, qps_remove = current_get - last_get, current_set - last_set, current_remove - last_remove
puts [ qps_get, qps_set, qps_remove, (qps_get + qps_set + qps_remove)].join("\t")
last_get, last_set, last_remove = current_get, current_set, current_remove
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment