Skip to content

Instantly share code, notes, and snippets.

@drwahl
Created February 17, 2016 22:51
Show Gist options
  • Save drwahl/bf1224861644a4847c9f to your computer and use it in GitHub Desktop.
Save drwahl/bf1224861644a4847c9f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import pprint
f = open('./foo', 'r')
counts = {}
for line in f.readlines():
tenant_id = line.split('|')[3].strip()
if line.split('|')[3].strip() not in counts.keys():
counts[tenant_id] = {'public_ips': 0,
'vms': 0}
counts[tenant_id]['vms'] = counts[tenant_id]['vms'] + 1
if ' 67.' in line.split('|')[7] or ' 173.' in line.split('|')[7] or ' 208.' in line.split('|')[7]:
counts[tenant_id]['public_ips'] = counts[tenant_id]['public_ips'] + 1
pp = pprint.PrettyPrinter(depth=6)
pp.pprint(counts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment