Skip to content

Instantly share code, notes, and snippets.

@abhi-bit
Created July 20, 2015 17:06
Show Gist options
  • Save abhi-bit/73ca4a14c3360eea6292 to your computer and use it in GitHub Desktop.
Save abhi-bit/73ca4a14c3360eea6292 to your computer and use it in GitHub Desktop.
import urllib2
import json
import subprocess
import sys
def main():
cluster_ip = sys.argv[1]
bucket = sys.argv[2]
bucket_map_url = "http://" + cluster_ip + \
":8091/pools/default/buckets/" + bucket
bucket_map_dump = json.loads(urllib2.urlopen(bucket_map_url).read())
server_list = bucket_map_dump['vBucketServerMap']['serverList']
print "Active item count"
print ""
for server in server_list:
cbstats_command = "/opt/couchbase/bin/cbstats " + server + \
" -b " + bucket + " all | grep -w curr_items"
proc = subprocess.Popen(cbstats_command, shell=True)
value = proc.communicate()
print ""
print "Replica item count"
print ""
for server in server_list:
cbstats_command = "/opt/couchbase/bin/cbstats " + server + \
" -b " + bucket + " all | grep -w vb_replica_curr_items"
proc = subprocess.Popen(cbstats_command, shell=True)
value = proc.communicate()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment