Created
October 21, 2016 20:04
-
-
Save luketlancaster/21ea1a71306416d9835245b5a15a7ca5 to your computer and use it in GitHub Desktop.
Speedtest Runner and Parser
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
#! /bin/bash | |
# This is a script to run the speedtest-cli command, you'll need to make sure it's | |
# installed and that you know the location of it. | |
# The speedtest-cli can be found at https://github.com/sivel/speedtest-cli | |
# Or, you can just use the following: | |
# $ curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py | |
# $ chmod +x speedtest-cli | |
# This file will need to be executable as well | |
# For ease of use, consider putting this in a Cron job, e.x. : | |
# */5 * * * * /Location/Of/Speedit/speedit.sh | |
# The above will run the speedtest every five minutes | |
# FILE is the location you'd like the CSV to be created in | |
FILE="/tmp/download_speeds.csv" | |
# SPEEDTEST is the location of the speedtest-cli executable | |
SPEEDTEST="/usr/local/bin/speedtest-cli" | |
# Right now, let's only worry about the Download speed. | |
DOWNLOAD_SPEED=$($SPEEDTEST --simple | grep "Download" | tr -s ':' | cut -d' ' -f2) | |
# If FILE cannot be found, let's make it and add the column titles to the top | |
if ! [ -f "$FILE" ]; then | |
echo "timestamp,download_speed" >> "$FILE"; | |
fi | |
# Append the date and DOWNLOAD_SPEED to the end of the CSV | |
echo $(date +%s)"," $DOWNLOAD_SPEED >> $FILE | |
# Uncomment the below to display notifications in notification center | |
# osascript -e "display notification \"$DOWNLOAD_SPEED\" with title \"Download Speed:\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment