Created
March 3, 2016 18:34
-
-
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.
This file contains 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 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 "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