Created
July 19, 2011 17:39
-
-
Save farshidce/1093217 to your computer and use it in GitHub Desktop.
hash-detail-and-print-vbucket-mismatch
This file contains 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
import commands | |
ips = ["10.1.5.38","10.1.5.53","10.1.5.54","10.1.5.57","10.1.5.58","10.1.5.59"] | |
def mapit(stuff): | |
rows = stuff[1].split("\n") | |
map = {} | |
for row in rows: | |
#get bucket id | |
vid = row[row.find("_")+1:row.find(":")] | |
vid = vid.replace(" ","") | |
vid = int(vid) | |
count = row[row.rfind(":")+1:] | |
count = count.replace(" ","") | |
map[vid] = int(count) | |
return map | |
cmd = "/opt/membase/bin/mbstats %s:11210 hash detail | grep :counted" | |
servers = {} | |
for ip in ips: | |
co = cmd % (ip) | |
print co | |
r = commands.getstatusoutput(co) | |
servers[ip] = mapit(r) | |
mismatch = [] | |
for server in servers: | |
print server | |
map = servers[server] | |
for vb in map: | |
if vb in mismatch: | |
continue | |
#loop through other | |
for others in servers: | |
othermap = servers[others] | |
if others != server: | |
if vb in othermap: | |
if othermap[vb] != map[vb]: | |
print "vbucket:",vb,server,map[vb],others,othermap[vb]," delta : " , abs(othermap[vb] - map[vb]) | |
mismatch.append(vb) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment