Measuring internet connection speed and graphing with Datadog

Joseph Miller
Jul 25, 2017 · 2 min read

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 ;)

Joseph Miller

Written by

Lead Software Engineer at Raisebook. Photographer, student pilot, dancer, space nerd.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade