Created
November 23, 2015 10:10
-
-
Save jdbevan/e7af4711ce7854131aff to your computer and use it in GitHub Desktop.
Speedtest-cli wrapper
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
#!/bin/bash -u | |
WDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
#timeout () { | |
# SLEEPTIME="$1" | |
# COMMAND="$2" | |
# ( cmdpid=$BASHPID; \ | |
# (sleep "$SLEEPTIME"; kill $cmdpid) \ | |
# & exec "$COMMAND" ) | |
#} | |
while [ true ] | |
do | |
RESULTS=`speedtest-cli` | |
# RESULTS=( cmdpid=$BASHPID; (sleep 60; kill $cmdpid) & exec speedtest-cli ) | |
if [ "$?" -eq "0" ]; then | |
PING=`echo "$RESULTS" | grep -o "[0-9]\+.[0-9]\+ ms" | grep -o "[0-9.]\+"` | |
DOWNLOAD=`echo "$RESULTS" | grep "^Download" | grep -o "[0-9.]\+"` | |
UPLOAD=`echo "$RESULTS" | grep "^Upload" | grep -o "[0-9.]\+"` | |
TIME=`date "+%Y-%m-%d %H:%M:%S"` | |
echo -e "$TIME\t$PING\t$DOWNLOAD\t$UPLOAD" >> "$WDIR/speedtest.log" | |
fi | |
sleep 300 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment