Used PimpMyLife setup here - https://pimylifeup.com/raspberry-pi-internet-speed-monitor/
If you didn't use the above link, make sure you setup InfluxDB's database NAME, LOGIN, and PASSWAORD when entering the data into Grafana.
I'm also not using the uplink to GDrive.
How you can set up your Raspberry Pi to monitor your internet connection and save the data to view in Grafana.
If you’re interested in monitoring how your download speed, upload speed, and ping are affected over time.
Additionally, this can help you work out what times your network may be at its peak capacity or if you’re suffering from a degraded internet connection.
It's a small Python script that interacts with a program called Speedtest CLI from Ookla.
Speedtest CLI is what our internet speed monitor will use to monitor the internet connection.
This program works by polling the popular speedtest.net service to get your ping, download speed, and upload speed.
Running the following command to list the servers that are located near you.
speedtest -L
Make a note of the ID for the server you want try connecting to.
Once you have an ID handy. Modify the following line in the Python script.
Find:
response = subprocess.Popen('/usr/bin/speedtest --accept-license', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
Replace:
'/usr/bin/speedtest --accept-license'
With:
'/usr/bin/speedtest --accept-license -s SERVERID'
Make sure that you replace SERVERID with the ID you retrieved from the previous list.
You should be able to update the speedtest-cli python package by running the following command.
pip install speedtest-cli --upgrade
IMPORTANT NOTE: If you use this, it will download a decently-large amount of data through your Internet connection on a daily basis. Don't use it, or tune the internet-monitoring setup to not run the speedtests as often, if you have a metered connection!
The easiest way to automate your script to run every so often is to make use of the crontab.
You can modify the crontab by running the following command on your Raspberry Pi.
crontab -e
This cronjob will run every 30 minutes.
*/30 * * * * python3 /home/pi/speedtest.py
Thanks to PimpMyLife!