Created
September 17, 2015 18:59
-
-
Save joegross/85a8b6e6d4754d80b582 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/python | |
import re | |
import subprocess | |
def speedtest_gmetric(): | |
speedtest = 'speedtest --simple --server 1783' | |
stdout = subprocess.check_output(speedtest.split()) | |
ping = re.search("Ping: (\S+)", stdout).group(1) | |
download = re.search("Download: (\S+)", stdout).group(1) | |
upload = re.search("Upload: (\S+)", stdout).group(1) | |
subprocess.call(('gmetric --name=speedtest.ping --dmax=3600 --value=%s --type=float --units=ms' % ping).split()) | |
subprocess.call(('gmetric --name=speedtest.download --dmax=3600 --value=%s --type=float --units=Mbits/s' % download).split()) | |
subprocess.call(('gmetric --name=speedtest.upload --dmax=3600 --value=%s --type=float --units=Mbits/s' % upload).split()) | |
if __name__ == '__main__' : | |
speedtest_gmetric() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment