Skip to content

Instantly share code, notes, and snippets.

@davipatti
Last active January 30, 2018 21:05
Show Gist options
  • Save davipatti/c2a381f6af93138c72d8e476fee0542e to your computer and use it in GitHub Desktop.
Save davipatti/c2a381f6af93138c72d8e476fee0542e to your computer and use it in GitHub Desktop.
Run internet speed test every 20 mins. Log the results and plot
/usr/local/bin/speedtest-cli --csv > ~/.speedtest.log.csv
# https://github.com/sivel/speedtest-cli
pip install speedtest-cli
#!/usr/bin/env python
import sys
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("darkgrid")
df = pd.read_csv(sys.stdin, index_col=3, parse_dates=[3, ])
df.loc[:, "Download"] /= 1e6
df.loc[:, "Upload"] /= 1e6
df.plot(y=["Download", "Upload"], figsize=(8, 5))
plt.ylabel("Mbit/s")
plt.savefig("download-upload-speed.png", bbox_inches="tight")
plt.close()
0,20,40 * * * * /usr/local/bin/speedtest-cli --csv >> ~/.speedtest.log.csv 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment