Created
October 7, 2019 17:58
-
-
Save esirK/594142a21b8c996d2a1f3833f90f05e7 to your computer and use it in GitHub Desktop.
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
# Network latency | |
""" | |
Here we will ping google at an interval of five seconds for five times and record the | |
min response time, average response time, and the max response time. | |
""" | |
ping_result = subprocess.run(['ping', '-i 5', '-c 5', 'google.com'], stdout=subprocess.PIPE).stdout.decode('utf-8').split('\n') | |
min, avg, max = ping_result[-2].split('=')[-1].split('/')[:3] | |
statistics['network_latency'] = dict( | |
{ | |
'min': min.strip(), | |
'avg': avg.strip(), | |
'max': max.strip(), | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment