This content originally appeared on Level Up Coding - Medium and was authored by Eric Klatzer
Are you also one of those people who are upset about slow Internet at home? This article could help you!
Introduction
Everyone of us may know the situation. You sit at home, want to download something or even only want to watch your series on Netflix, but there is one problem. Your network connection is too slow again. This article will show you a guide on how you can monitor your network speed at home and try to convince your provider to get a faster connection or maybe at least pay a little less.
System Structure
To monitor your network speed at home the following steps are needed:
- Recurring speedtest from your local network at different times of the day
- Collection of the speedtest results in a database (in this case InfluxDB)
- Visualization of the data with Grafana

All the needed steps will be described in this article and all needed tools can be found in this Github repository:
Prerequisite
In order to be able to set up speedtest-tool a unix-like operating system with Docker and Docker Compose are needed. Install instructions for those two tools can be found here:
- Docker Engine: https://docs.docker.com/engine/install/
- Docker Compose: https://docs.docker.com/compose/install/
Setup
The following steps need to be done to set up the tool to monitor your download-, upload- and ping-statistics and automatically visualize them. To get realistic values a wired internet connection should be chosen over a wireless one.
CLI Tools
The first step in the setup is the installation of the needed CLI tools, which are: speedtest, jq, curl .
- speedtest: a CLI tool to run a speedtest
- jq: a tool to handle JSON
- curl: a tool to make server requests (in this case HTTP-calls in the installation process and to insert data into the database)
The tools can be manually installed, or the install.sh can be used.
Further install instructions for the speedtest-clican be found here: Install instructions
To execute a speedtest, the command speedtest has to be used. During the first use the license has to be accepted. The output contains some details about the used speedtest-server and the speedtest-result.
To get the result as JSON the parameter --format=json has to be used.
InfluxDB & Grafana
InfluxDB is a time-series database that is in this case used to store the speedtest-results. Grafana is used to visualize the values without much effort. To simplify this process, Docker or more in detail Docker Compose is used. Docker Compose was developed to help define and share multi-container applications. In this case two containers, influxdb:1.8 and grafana/grafana:latest are used. Normally, when using Docker, the data is gone, when the container is stopped. To persist the data volumes are used. Additionally, environmental variables are set, which are for example needed to set the credentials of the services. The credentials are stored in the file .env :
The values of this file are used in the following docker-compose.yml:
To have access to the predefined dashboards and the data source needed to get access to InfluxDB in Grafana, the directory grafana is needed. It makes use of the provisioning feature which is offered by Grafana and is in this case done with the volume ./grafana:etc/grafana/provisioning .
To start the database and Grafana the command docker-compose up is used. To validate the status of the service, the command docker-compose ps is used:
Both services should be and stay in the status Up .
Speedtest Execution
To get data into the database, the following steps have to be done:
- Execution of a speedtest
- Extraction of the needed values from the result
- Insertion of the values into the database
Therefore the following bash script can be used, which does the following steps:
- Load the variables from .env
- Run a speedtest with the flag --format=json which instructs the speedtest to return the result as JSON
- Extraction of the needed values (ping, download, upload) from the JSON
- Insertion of the values into InfluxDB
Automation
To automate the speedtest a cronjob can be used. Cron is used for scheduling tasks on unix-like operating systems. Therefore a cronjob that runs speedtest.sh at your given interval (Crontab-Guru) has to be configured. To configure a cronjob the command crontab -e has to be used. At the end of the file the following line has to be inserted:
* * * * * /path/to/speedtest.sh
For getting more specific scheduling expressions, Crontab Guru can be used.
Visualization
Grafana is used to visualize the stats that have been collected and inserted into the database. If the Docker setup is started, Grafana can be reached by opening http://localhost:3000 in your browser (default credentials: user=admin, password=admin). To view the graph for the speedtest stats the dashboard Speedtest has to be opened using the left navigation bar. The dashboard and the access to InfluxDB are already preconfigured because the provisioning feature was used. The unit of upload and download are bytes per second. The unit of the ping is milliseconds.

Conclusion
After the collection of your speedtest stats over a while and at different times of the day the results can be compared to the bandwidth offered by your provider. Leave a comment comparing your expected value with the bandwidth you really get.
The repository for the speedtest-tool can be found here:
Do You Pay Too Much for Your Network Contract? was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Eric Klatzer

Eric Klatzer | Sciencx (2022-04-19T14:30:11+00:00) Do You Pay Too Much for Your Network Contract?. Retrieved from https://www.scien.cx/2022/04/19/do-you-pay-too-much-for-your-network-contract/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.