Created
September 2, 2017 02:53
-
-
Save c4urself/3592a09aa3ce10fd55f76120a37465bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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