Skip to content

Instantly share code, notes, and snippets.

@farshidce
Created July 19, 2011 17:39
Show Gist options
  • Save farshidce/1093217 to your computer and use it in GitHub Desktop.
Save farshidce/1093217 to your computer and use it in GitHub Desktop.
hash-detail-and-print-vbucket-mismatch
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