Measuring internet connection speed and graphing with Datadog

Being a “devops” kind of person, I have a weird love for graphs. Also, I recently heard a lot of talk about how the ISP I have been using…

Measuring internet connection speed and graphing with Datadog
Photo by fabio / Unsplash

Being a “devops” kind of person, I have a weird love for graphs. Also, I recently heard a lot of talk about how the ISP I have been using has seen a lot of degradation in performance since it was bought out by another entity.

Not being one to blindly believe rumours, I thought I could do some measurements and find out if it was time to switch.

Using a combination of speedtest-cli and statsd, and taking some inspiration from the post I co-wrote a few years ago at Redbubble, I put together a small script which I could run on a once-every-ten-minutes cronjob:

#!/bin/bash

STATS=`/usr/local/bin/speedtest-cli --json --server 2169 --bytes | /usr/bin/jq '.ping,.download,.upload'`

PING=`/bin/echo ${STATS} | /usr/bin/awk '{printf "%d", $1}'`
DOWNLOAD=`/bin/echo ${STATS} | /usr/bin/awk '{printf "%d" ,$2}'`
UPLOAD=`/bin/echo ${STATS} | /usr/bin/awk '{printf "%d", $3}'`

/bin/echo "skymesh.ping:${PING}|g" | nc -w 1 -u localhost 8125
/bin/echo "skymesh.download:${DOWNLOAD}|g" | nc -w 1 -u localhost 8125
/bin/echo "skymesh.upload:${UPLOAD}|g" | nc -w 1 -u localhost 8125

Note — I already had the datadog agent running on my linux machine at home, and it was set to have dogstatsd listening on the UDP port 8125

Datadog happily graphing values from statsd

Et voilà! Once this was running, data started to flow right into Datadog!

Conclusion: At consistently ~96Mbit download and ~30Mbit upload, I’m pretty happy with my connection. Latency is looking a bit off though, might need to investigate that ;)