Last active
June 28, 2017 03:19
-
-
Save ntrepid8/e2b052f292eede44df7d54b959fd8a08 to your computer and use it in GitHub Desktop.
Shell script to use with speedtest-cli and parse_speedtest_simple.py
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
#!/usr/bin/env bash | |
DATE_TAG="$(date -u +"%Y")-$(date -u +"%m")" | |
CSV_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv" | |
LOG_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv.log" | |
# ensure the path exists | |
mkdir -p $(dirname "${CSV_PATH}") | |
# add the header row if the file does not exist | |
if [ ! -f "${CSV_PATH}" ]; then | |
printf '"date_time","ping (ms)","download (Mbit/s)","upload (Mbit/s)"\n' >> "${CSV_PATH}" | |
fi | |
# run speedtest and record the results | |
if result=$(/usr/bin/speedtest --simple | parse_speedtest_simple.py); then | |
printf "${result}\n" >> "${CSV_PATH}" | |
else | |
printf "[$(date)] error\n" >> "${LOG_PATH}" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use with: https://gist.github.com/ntrepid8/c5aec63d2f731b6575f8f5e5cebbf39f