I’ve been seeing some pretty big variations in my broadband speed, and want to schedule a speed test, something along the lines of speedtest.net, in an automated way that doesn’t use flash.
Using my raspberry pi, cron and this speedtest cli python script from GitHub, I’m now logging my broadband speed every 15 minutes.
Here are the commands I used:
sudo apt-get install python3-pip
sudo pip-3.2 install git+https://github.com/sivel/speedtest-cli.git
By default it will pick out the nearest server, but I specifically want to use a speedtest server within Virgin Media’s network so that I’m as few network hops away as possible.
I can now see that one of Virgin Media’s London servers is number 3728, so in future I can use
to select that server every time. I can also look at http://www.speedtest.net/speedtest-servers.php to see the full server list.
I created a script that logs the time, and outputs the speed test to the file:
date +"|%d/%m/%Y %H:%M" >> log.txt
speedtest --simple --server 3788 >> log.txt
chmod +x logspeed
Let’s run this every 15 minutes
add the line
*/15 * * * * ./logspeed
I’ve backed this off a little, as at 100MB each time, it’s using a reasonable amount of data each day.
However it would be much nicer to see this in graphical form, so I’ve created the ASP.NET MVC project https://github.com/jamielaundon/speedtest-logger. This makes a small tweak to the python script, and instead of posting test results to speedtest.net, we post to a logging server instead. We store the results, and then display them using graphs generated by Google Chart.
You can see the final results here: https://jamie.laundon.org/speedtest-logger/ where at the time of writing we can clearly see there is a big drop-off of speed between 7pm and 11pm each night. I’m assured by my ISP that capacity upgrades will take place over the coming weeks, so I’ll check the results occasionally and see if they have delivered on their promise.
It’s been a good project to learn a few new tricks using MVC, the SQL Micro-ORM called Dapper, and dig a bit deeper into the Google Chart API.