Skip to content

Instantly share code, notes, and snippets.

@c4urself
Created September 2, 2017 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c4urself/3592a09aa3ce10fd55f76120a37465bd to your computer and use it in GitHub Desktop.
Save c4urself/3592a09aa3ce10fd55f76120a37465bd to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re
import sys
keyspace, table, size_in_gb = 'unknown', 'unknown', 0.0
for line in sys.stdin.readlines():
if 'Keyspace:' in line:
m = re.search(r'Keyspace: (?P<keyspace>\w+)', line)
keyspace = m.group('keyspace')
continue
if 'Table:' in line:
m = re.search(r'Table: (?P<table>\w+)', line)
table = m.group('table')
continue
if 'Space used (total):' in line:
m = re.search(r'Space used \(total\): (?P<size>\d+)', line)
size_in_bytes = int(m.group('size'))
size_in_gb = size_in_bytes / 1024.0 / 1024.0 / 1024.0
print(keyspace, table, size_in_gb)
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment