While measuring latency of your internet link over time is as simple as something like this;

 docker run -p 8000:80 -d dperson/smokeping -w -t "ISP;DNS;8.8.8.8"

I couldn’t find anything which would give a good measure of bandwidth consistency over time.

Now this is understandable, you need to use bandwidth to properly measure bandwidth (especially if you don’t run the infrastructure), so it’s a less useful tool in the regular network engineers arsenal, with useful tools such as Speedtest.NET designed for a one-off, point in time check of internet speed.

But with considerable oversubscription common amongst home ISP’s, I was looking for a way to graph trends in my internet connectivity, at an interval which wouldn’t cause the network issues, but would give me a lot more insight than the occasional, manual test.

This is when I stumbled upon https://github.com/sivel/speedtest-cli; An excellent python implementation of the web-browser client for the Speedtest.NET. Suddenly, we have a decent command line interface to Speedtest.NET!

speedtest-cli matjohn2$ ./speedtest.py
Retrieving speedtest.net configuration...
Testing from ISP (LOCAL IP ADDR)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by SPONSOR (CITY) [7.17 km]: 21.799 ms
Testing download speed.........................................................................
Download: 354.59 Mbit/s
Testing upload speed.........................................................................
Upload: 203.96 Mbit/s

There are even options to output the results to CSV or JSON, ideal for most!

But what if we want this to be truly hands off monitoring? Enter Plot.ly and Docker!

Plotly gives us an API and python bindings to easily submit and update data to a plotly hosted graph… for free (as long as the graphs are public, which is cool).

So I added some basic plotly support.

Gives us a graph in plotly like this…

Run it again; you get a second data point.

Enter docker… and we can package this up into a one-hit measurement command which will run anywhere, adding each new dataset (with timestamp) to the graph.

You can run this yourself with one command;

docker run -v /root/.plotly:/root/.plotly trxuk/speedtest-plotly:1

All you’ll need is a plot.ly API key (which you see us passing into the container with the -v directory mount).

I’ve added more plotly info to the readme in the PR to speedtest-cli for those that want to know more;

https://github.com/matjohn2/speedtest-cli/blob/dbb1e9ae1e295920141377be4649a6505b897b01/README.rst

And here’s my live graph (click for live).

 

 

 

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.