Skip to content

Instantly share code, notes, and snippets.

@JustAPerson
Created May 11, 2019 17:44
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 JustAPerson/d7e0c25ad60b91e2b9c6614298e64469 to your computer and use it in GitHub Desktop.
Save JustAPerson/d7e0c25ad60b91e2b9c6614298e64469 to your computer and use it in GitHub Desktop.
convert output of `ping domain > file` into a graph
import sys
import re
import matplotlib.pyplot as plot
file_name = sys.argv[1]
with open(file_name) as f:
data = f.read()
domain = re.search('PING (.+) 56', data)
seq = re.findall('icmp_seq=(\d+)', data)
time = re.findall('time=([\d\.]+) ms', data)
seq = list(map(int, seq))
time = list(map(float, time))
plot.title(domain.group(1))
plot.ylabel('rtt (ms)')
plot.xlabel('time (s)')
plot.plot(seq, time)
plot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment