Skip to content

Instantly share code, notes, and snippets.

@drewr
Created January 7, 2011 03:26
Show Gist options
  • Save drewr/769063 to your computer and use it in GitHub Desktop.
Save drewr/769063 to your computer and use it in GitHub Desktop.
import sys, json, functools, time
if sys.stdin.isatty():
data = json.loads(file("/tmp/status").read())
else:
data = json.loads(sys.stdin.read())
bytes = 0
docs = 0
shardn = 0
for name, vals in data["indices"].items():
for i, replicas in vals["shards"].items():
for r in replicas:
if r["routing"]["primary"] == True:
bytes += r["index"]["size_in_bytes"]
docs += r["docs"]["num_docs"]
shardn += 1
try:
bytes_per_doc = bytes/docs
except ZeroDivisionError:
bytes_per_doc = 0
print int(time.time()), shardn, bytes, docs, bytes_per_doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment