3

Afternoon,
Is there software available for monitoring our broadband quality over time? Our dsl internet connection drops off a couple of times a day, usually for only a short period of time, but sometimes longer. I am working with our service provider to try and figure out whats going on, and they are sending a technician, but I would like to provide the technician with a more detailed idea of how often it fades out and when. We do have a new provider who is taking the issue more seriously but after having this problem for a few years, I would like to provide more information to them as to the extent. They can certainly tell when I call when we are out, but they made no indication that they have records over time although I have asked. thanks.

KeepingUp
  • 111

1 Answers1

2

You can monitor the download speed quite easily without having to install anything. You can use wget to download a file from a speedtest site and calculate the speed from the size and time:

#!/bin/bash
a=$(wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip 2>&1)
t=$(echo "$a"|grep 100%)
t=${t#*=}
t=${t%s}
l=$(echo "$a"|grep Length)
l=${l#*Length: }
l=${l% (*}
s=$(python -c "print '%.2f'%($l*8/$t/1e6)")
d=$(date +"%Y%m%d_%H%M%S")
echo -e "$d\t$s"

This script just saves the output of wget into a variable and then does a little bit of hacky bash to extract the time from the line where the download completes (containing 100%) and the size from the line which gives the "Length" of the file. It then uses python to calculate the speed in Mbits/s. Finally we echo the date (YearMonthDay_HourMinSec) and the speed to the screen.

If you save this as speed.sh in you home directory. And then make it executable by opening a terminal in your home directory and running.

chmod +x speed.sh

Now test it works by running

./speed.sh

If that is all fine we need to just make it run regularly and output to a text file with cron. Run:

crontab -e

(If it asks you to select and editor select nano unless you know and love another option). Use the arrow keys to navigate to the bottom of the file and type

*/5 * * * * /home/USERNAME/speed.sh>>/home/USERNAME/speed.txt

Here you should replace USERNAME with your username. This will run the script every 5 mins. For every 10 mins replace with:

*/10 * * * * /home/USERNAME/speed.sh>>/home/USERNAME/speed.txt

or every hour

0 * * * * /home/USERNAME/speed.sh>>/home/USERNAME/speed.txt

Exit the editor (Ctrl+x in nano), and say yes to save.

Now the download speed should log to the .txt file in your home directory however often you want with a date stamp before it.

A test example running every 2 mins on my PC produced:

20160731_153804 29.77
20160731_154005 29.77
20160731_154205 23.07
20160731_154404 29.77
20160731_154621 13.18
20160731_154805 29.77
20160731_155004 29.77
20160731_155206 18.10
20160731_155404 29.77