Created
March 18, 2013 03:50
-
-
Save jeremyvisser/5184955 to your computer and use it in GitHub Desktop.
Simple speed logging used for graphing variation. Log output is tab-delimited, which is very easy to put into a spreadsheet and turn into a graph. Logrotate is used to e-mail results daily.
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
# file: /etc/cron.d/speedtest | |
* * * * * root /usr/local/bin/speedtest 2>/dev/null >>/var/log/speedtest.log |
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
# file: /etc/logrotate.d/speedtest | |
/var/log/speedtest.log { | |
missingok | |
notifempty | |
daily | |
rotate 30 | |
create 0644 root root | |
prerotate | |
echo "Timestamp Secs Mbit/s" | cat - /var/log/speedtest.log | mail -s 'Speed test results' myself@example.com | |
endscript | |
} |
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 | |
# file: /usr/local/bin/speedtest | |
set -e | |
pgrep '^nc$' >/dev/null && pkill '^nc$' | |
DATE=`date '+%Y-%m-%d %H:%M:%S'` | |
DURATION=`/usr/bin/time -f '%e' nc speedtest.mydomain.com 8888 2>&1 >/dev/zero` | |
# Size is assumed to be 10MB worth of \0's | |
RATE=`echo "scale=2; 10/$DURATION*8" | bc -l` | |
echo "Timestamp Secs Mbit/s" >/dev/fd/2 | |
echo "$DATE $DURATION $RATE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment