Created
October 4, 2013 15:37
-
-
Save 0xAB41/6827960 to your computer and use it in GitHub Desktop.
quick script to calculate hit ratio of memcached servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| #run the following bash one liner to gather statistics first followed by python script to calculate hit ratio & average hit ratio | |
| #for i in mem-node{1..30}; do (echo "stats"; sleep 2 ) | telnet $i 11211 | grep get_ ; done > stats; python avg.py stats | |
| import sys | |
| from __future__ import division | |
| x = [int(i.strip().split()[2]) for i in open(sys.argv[1]).readlines()] | |
| hitratios=[x[2*i]/(x[2*i]+x[2*i+1]) for i in range(len(x)/2)] | |
| for hr in hitratios: | |
| print hr | |
| print "average: "+str(sum(hitratios)/len(hitratios)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment