Skip to content

Instantly share code, notes, and snippets.

@JustinAzoff
Created March 3, 2016 18:34
Show Gist options
  • Save JustinAzoff/234e057b207d29b5645c to your computer and use it in GitHub Desktop.
Save JustinAzoff/234e057b207d29b5645c to your computer and use it in GitHub Desktop.
Aggragate netstats output across myricom workers accounting for their misreporting of dropped packets bug.
#!/usr/bin/env python
import sys
import re
from collections import defaultdict
totals = defaultdict(int)
host_dropped = {}
total_rx = total_drop = 0
for line in sys.stdin:
parts = re.split('[ =:]+', line.strip())
node, time, _, recvd, _, dropped, _, link = parts
host = node[:-2]
totals[host] += int(link)
total_rx += int(link)
if host not in host_dropped:
total_drop += int(dropped)
host_dropped[host] = int(dropped)
for host, total in sorted(totals.items()):
if not total: continue
d = host_dropped[host]
print "%s dropped=%d rx=%d %0.2f%%" % (host, d, total, 100.0*d/total)
print
print "Totals dropped=%d rx=%d %0.2f%%" % (total_drop, total_rx, 100.0*total_drop/total_rx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment