One thing you may wish to graph is your internet speed.
Lucky someone has already created a script we can ‘borrow’
Here is the author’s GitHub

The only thing you may wish to change is the DATABASE=”XXXXX” to suit the database you want the script to insert into.
We are going to create another database just for speedtest results.



[ -f /etc/default/speedtest_tester ] && . /etc/default/speedtest_tester

while [[ $# > 0 ]]; do

 case $key in
 echo "Unknown option $key"

timestamp=$(date +%s%N)
output=$(speedtest-cli --simple)

line=$(echo -n "$output" | awk '/Ping/ {print "ping=" $2} /Download/ {print "download=" $2 * 1000 * 1000} /Upload/ {print "upload=" $2 * 1000 * 1000}' | tr '\n' ',' | head -c -1)
curl -XPOST "http://$INFLUXDB_HOST:$INFLUXDB_PORT/write?db=$DATABASE" -d "speedtest,host=$hostname $line $timestamp"

#Sudo nano /etc/default/
Copy this to your clipboard.
Jump over to a SSH session to your Virtual Machine, and run the following to create a .sh script

To make it executable run this!

#sudo chmod u+x /etc/default/

We need some further software to actually run the speedtest, obtain that by running:

#sudo apt-get install speedtest-cli


Go to the Influx DB admin page on <YOURSERVERIP>:8083
If you want to keep these results separate to your other Database as mentioned at the start of this article, you can create one now.

Click Query Templates –> Create Database

Change to query to be CREATE DATABASE “speedtest”

Press Enter!

Its time to test if this script is working, run the following command and wait a few moments.

#sudo /etc/default/

To check it is writing info to Influx, Go to the admin console, ensure you have the ‘speedtest’ database selected and run SHOW MEASUREMENTS, You should see the word speedtest listed.

Now login to Grafana and add a new Datasource.

Default= unchecked
Type= InfluxDB
URL= http://localhost:8086

Now make sure when you press Save and test that it is functioning correctly.

Navigate to an existing Dashboard, or create a new one and select a new graph,
You need to pay attention to where you are getting data from, delete the one that automatically adds,
Select +Add Query from the Panel Data Source when you have the speedtest database selected.

The 3 queries I used are:

SELECT mean(“download”) FROM “speedtest” WHERE “host” = ‘Netmon3’ AND $timeFilter GROUP BY time($interval) fill(null)

SELECT mean(“upload”) FROM “speedtest” WHERE “host” = ‘Netmon3’ AND $timeFilter GROUP BY time($interval) fill(null)

SELECT mean(“ping”) FROM “speedtest” WHERE “host” = ‘Netmon3’ AND $timeFilter GROUP BY time($interval) fill(null)

Make the graph really pretty by selecting bars, and lines under Display. Or not, whatever, you can make it look pretty from here!
SAVE the dashboard now.


Jump back into the SSH Session and lets schedule this with CRON.

#Sudo nano /etc/crontab
Pate the following line at the bottom:

0 * * * * root /etc/default/

Happy Days!

More to come!




Want to run this Internet Speedtest between certain hours only?
Use this line in the Cron file instead of the one above!

00 9-17/1  * * * root /etc/default/


EDIT # 2:
CentOS Configuration:

It took me a little longer to get the same script running on CentOS, Put the and the file in /usr/local/src/

Change the permissions on the .sh file with the same Chmod command above, updated for the new file location.


Super Simple Simon Grafana setup PART 2 – Internet Speed Test

Leave a Reply

Your email address will not be published. Required fields are marked *