This page explains how to install and run Speedtest (from Ookla) on a Raspberry pi.
Download speedtest-cli from GitHub by running the following command:
sudo wget -O /usr/local/bin/speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
Then
sudo chmod a+x /usr/local/bin/speedtest-cli
The following script (speedtest.sh) can be used to check the results of Speedtest at regular intervals (crontab):
#!/bin/bash -e
# This routine is meant to test the speed of the network at regular interval (defined in Crontab)
download=''
upload=''
HOSTNAME=`hostname`
/usr/local/bin/speedtest-cli > result
download=`awk '/Download:/ {print $0}' result`
echo $download
upload=`awk '/Upload:/ {print $0}' result`
echo $upload
curl -s \
--form-string "token=ax7sksu67nutgys42uiymny2sxhya2" \
--form-string "user=u6ysovfgq1nhysszxzh91qnwadch2y" \
--form-string "title=$HOSTNAME - Speedtest"\
--form-string "message=$download - $upload!" \
https://api.pushover.net/1/messages.json
exit