I run this on the same Raspberry PI 4 that hosts Pi-Hole in my local network. Uses:
- Python3
- Flask
- Chart.js
- SQLite3
- Cron
Speedtest part based on https://pimylifeup.com/raspberry-pi-internet-speed-monitor/ and adopted to use SQLite3 as database instead of CSV file.
Flask part based on https://github.com/johnsliao/flask-sqlite3-chartjs-toy
- Follow the installation instructions for the Ookla speedtest library on https://pimylifeup.com/raspberry-pi-internet-speed-monitor/
- Clone repository
git clone https://github.com/mkoegel/speedtest4pi.git
- Install dependencies
pip3 install -r requirements.txt
- Create Database
sqlite3 speedtest.db < schema.sql
- Setup your crontab with `sudo crontab -e``
- Enter
0 * * * * python3 /home/pi/speedtest4pi/speedtestdb.py
to run the test every hour. - Start the Flask app with
flask run -h <hostname or ip>&
. Note: Flask is not a production webserver. Never use if your PI is exposed to the internet. - Open browser to
http://<hostname or ip>:5000/
. You see the linechart with your Internet Data.
If you used this before make sure to remove the old speedtest-cli and update your packages.
pip3 uninstall speedtest-cli
pip3 install -r requirements.txt
- Integrate into Pi-Hole UI once Pi-Hole 5 is out of beta.
- Use a full fledged webserver.