Skip to content

Instantly share code, notes, and snippets.

@gkralik
Last active March 24, 2022 09:39
Show Gist options
  • Save gkralik/3bd19bfb553341dcfc12da01c00138d4 to your computer and use it in GitHub Desktop.
Save gkralik/3bd19bfb553341dcfc12da01c00138d4 to your computer and use it in GitHub Desktop.
Periodically measure internet connection speed using speedtest-cli

install speedtest-cli

$ pip install speedtest-cli

add to crontab

$ crontab -e

# run speedtest every 10 min
*/10 * * * * (/usr/bin/speedtest-cli --simple --server 3199 | awk  -v date="$(date +\%Y-\%m-\%d\ \%H:\%M:\%S)" -v OFS=';' '/Ping:/ { p=$2; } /Download:/ { d=$2; } /Upload:/ { print date, p, d, $2; d="" }' | tee -a /home/user/speedtest_results.csv)

analyze data

measurements are stores as CSV (using a semicolon as delimiter) with the following format:

date (yyyy-mm-dd hh:mm:ss);ping (ms);down rate (mbit/s);up rate (mbit/s)

@Jafar412
Copy link

Thank you for this quick solution..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment