Speedtest.net graphing

Julkaistu 13.8.2015 kirjoittanut Jyrki Pesonen
Howto: speedtest-cli with rrd

There are several howto’s(link is external) around on how to install and use speedtest-cli(link is external), the commandline flavor of Ookla -based test site(link is external).

I wanted something more, not much but being curious on what happens around in my small systems, I stapled together this pile of spaghetti…

It uses speedtest-cli(link is external) as initial data input, RRDtool(link is external) as visualizer, bash and misc programs related to it, and whatever (link is external)webserver for publishing. I’m not guru on bash, mentioning this ’cause I do enjoy good omg-w4tDidUDo -spam from the ones that are…

1. Install speedtest-cli and make sure it works:

wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py

sudo mv speedtest_cli.py /usr/local/bin/speedtest-cli

sudo chmod a+rx /usr/local/bin/speedtest-cli


(in case you didn’t figure above out, just head to the website(link is external) and don’t bother reading more)

After final command you should get results on your ping, upload and download. Let’s move forward.

2. Write code that figures out your hometown server and uses it to test speed and gives you a nice pic to share the results. (using vi is considered ultrageeky, reason why I nano)

mkdir -p /usr/src/scripts/speedtest

nano /usr/src/scripts/speedtest/get_my_speedtest_status.sh

# This is ’what speedtest-cli –server XXXXX –share’ typically gives:
# Retrieving speedtest.net configuration…
# Retrieving speedtest.net server list…
# Testing from Masternet Inc (…
# Hosted by Masternet Inc (Eastwesttown) [1.41 km]: 15.286 ms
# Testing download speed………………………………….
# Download: 98.56 Mbit/s
# Testing upload speed…………………………………………..
# Upload: 1.91 Mbit/s
# Share results: https://www.speedtest.net/result/076719.png

cd /usr/src/scripts/speedtest
DATE=`/bin/date ”+%Y.%m.%d-%H%M%S”`

#this a regexp to figure out numbers most of the kind



# Replace this with our known city


MYSERVER=`/usr/local/bin/speedtest-cli –list | grep -i $MYTOWN|awk ’{print $1}’|sed -e ”s/)//g”`
#echo ”server=$MYSERVER”
if [[ $MYSERVER =~ $re ]] ;
MYRETURN=`/usr/local/bin/speedtest-cli –server $MYSERVER –share`
# echo ”return=$MYRETURN”
echo ”$MYRETURN”>tmp
# cat tmp
MYPING=`cat tmp|grep -i ”^Hosted by”|awk ’{print $(NF-1)}’`
# echo ”ping=$MYPING”
MYUPLOAD=`cat tmp|grep -i ”^Download”|awk ’{print $(NF-1)}’`
# echo ”uplink=$MYUPLOAD”
MYDOWNLOAD=`cat tmp|grep -i ”^Upload”|awk ’{print $(NF-1)}’`
# echo ”downlink=$MYDOWNLOAD”
MYLINK=`cat tmp|grep -i ”^Share results”|awk ’{print $(NF)}’`
echo $MYLINK>/var/www/speedtest/lastlink2pic
# echo ”piclink=$MYLINK”

if [[ $MYPING =~ $re ]] && [[ $MYUPLOAD =~ $re ]] && [[ $MYDOWNLOAD =~ $re ]] ;
# echo ”Got values:”
echo ”$MYPING”
echo ”$MYUPLOAD”
# echo ”NO values:”
echo ”0”
echo ”0”
echo ”0”

And then save.

3. Make another code that uses above to dump the data into RRD:

nano /usr/src/scripts/speedtest/update_my_speedtest_rrd

DATE=`/bin/date ”+%Y.%m.%d %H:%M:%S”`
MYMONTH=`/bin/date ”+%Y-%m-%d”`
MYDATA=`cat /var/www/speedtest/raw.txt|tail -n20|gawk ’BEGIN{ORS=”:”;i=0;}{print;i=i+1;}END{if(i<3) for(;i<3;i++)print ”-400”;}’|sed -e ’s/:$//g’` echo -e ”$MYDATA\r\n” echo -e ”$DATE:$MYDATA”>>/var/www/speedtest/log-$MYMONTH.txt
rrdtool update $MYPATH N:$MYDATA

and save,

4. Now create initial RRD database, you might want to read few faq’s around the net on rrdtool create.

nano /usr/src/scripts/speedtest/create_my_speedtest_rrd

DATE=`/bin/date ”+%Y.%m.%d-%H%M%S”`


rrdtool create ”$MYPATH” \
–start N –step 3600 \
DS:MY-PING:GAUGE:7200:0:6000 \
DS:MY-DOWNLINK:GAUGE:7200:0:3000 \
DS:MY-UPLINK:GAUGE:7200:0:3000 \

RRA:MIN:0.5:60:8785 \
RRA:MAX:0.5:60:8785 \

save and run:

mkdir -p /var/www/speedtest

bash /usr/src/scripts/speedtest/create_my_speedtest_rrd

5. now create code for updating the graphs:

nano /usr/src/scripts/speedtest/graph_speedtest_rrd


DATE=`/bin/date ”+%Y.%m.%d-%H%M%S”`
# last 12hours: –end now –start end-43200s
# last 24hours: –end now –start end-86400s
# last week: –end now –start end-604800s
# last month: –end now –start end-2419200s
# last year: –end now –start end-31536000s

PARAMS_ARRAY=(”–” ”-s e-12h” ”-s e-24h” ”-s e-1w” ”-s e-1m” ”-s e-1y”)
TITLE_ARRAY=(”” ”Last 12h” ”Last 24h” ”Last week” ”Last month” ”Last year”)
FILENAME_ARRAY=(”a” ”12h” ”24h” ”week” ”month” ”year”)

#DS:MY-PING:GAUGE:120:0:6000 \
#DS:MY-DOWNLINK:GAUGE:120:0:3000 \
#DS:MY-UPLINK:GAUGE:120:0:3000 \

for N in {0..5}
rrdtool graphv -J ”$MYPATH”my-ping-”${FILENAME_ARRAY[$N]}”.png -a PNG –title=”Ping ${TITLE_ARRAY[$N])}” \
–vertical-label ”ms” \
”DEF:T=speedtest.rrd:MY-PING:AVERAGE” \
”DEF:TMIN=speedtest.rrd:MY-PING:MIN” \
”DEF:TMAX=speedtest.rrd:MY-PING:MAX” \
’AREA:TMIN#00ff00:Ping min’ \
’AREA:TMIN#ffb6c1:Ping max’ \
’LINE1:T#ff0000:Ping’ \
’GPRINT:T:LAST:Last Ping\: %2.1lf ms’ \
’GPRINT:TMAX:MAX:Max Ping\: %2.1lf ms’ \
’GPRINT:TMIN:MIN:Min Ping\: %2.1lf ms’

rrdtool graphv -J ”$MYPATH”my-downlink-”${FILENAME_ARRAY[$N]}”.png -a PNG –title=”Downlink speed ${TITLE_ARRAY[$N])}” \
–vertical-label ”Mbit/s” \
”DEF:T=speedtest.rrd:MY-DOWNLINK:AVERAGE” \
”DEF:TMIN=speedtest.rrd:MY-DOWNLINK:MIN” \
”DEF:TMAX=speedtest.rrd:MY-DOWNLINK:MAX” \
’AREA:TMIN#00ff00:Down min’ \
’AREA:TMIN#ffb6c1:Down max’ \
’LINE1:T#ff0000:Downlink’ \
’GPRINT:T:LAST:Last downlink\: %2.1lf Mbit/s’ \
’GPRINT:TMAX:MAX:Max downlink\: %2.1lf Mbit/s’ \
’GPRINT:TMIN:MIN:Min donwlink\: %2.1lf Mbit/s’

rrdtool graphv -J ”$MYPATH”my-uplink-”${FILENAME_ARRAY[$N]}”.png -a PNG –title=”Uplink speed ${TITLE_ARRAY[$N])}” \
–vertical-label ”Mbit/s” \
”DEF:T=speedtest.rrd:MY-UPLINK:AVERAGE” \
”DEF:TMIN=speedtest.rrd:MY-UPLINK:MIN” \
”DEF:TMAX=speedtest.rrd:MY-UPLINK:MAX” \
’AREA:TMIN#00ff00:Up min’ \
’AREA:TMIN#ffb6c1:Up max’ \
’LINE1:T#ff0000:Uplink’ \
’GPRINT:T:LAST:Last uplink\: %2.1lf Mbit/s’ \
’GPRINT:TMAX:MAX:Max uplink\: %2.1lf Mbit/s’ \
’GPRINT:TMIN:MIN:Min uplink\: %2.1lf Mbit/s’


6. Easy, eh? Now prepare minimalistic index.php:

nano /var/www/speedtest/index.php

echo ”\t

echo ”\t

echo ”\t

echo ”


7. almost done, set things up in crontab:

sudo crontab -e

1 * * * * nice -n 19 bash /usr/src/scripts/speedtest/update_my_speedtest_rrd>/dev/null 2>&1
3 * * * * nice -n 19 bash /usr/src/scripts/speedtest/graph_speedtest_rrd>/dev/null 2>&1

8. Done. Now wait and later check the site, it should look a bit like this:

Over and out…
Source: http://jyge.fi/2015/08/13/howto-speedtest-cli-with-rrd/

Sonos hidden web interface

Thanks bsteiner.info:

The Hidden Sonos Web Interface

Sonos ConnectGetting started

Sonos controllers interact with the players through the HTTP protocol. It is actually possible to directly use this underlying interface to communicate with the players without being limited by the feature set made available in the controller.

In order to access this interface, you first need the IP address of the player you want to interact with. It is listed in the “about my Sonos system” menu of the Sonos controller. We’ll refer to it as <sonos_ip> below.

Status Screen

The status screen can be used to gain insight into the player setting, its hardware, and its environment. It is available at the following URL:


The screen displays a large collection of submenus that you can explore at your leasure. Many of these menus such as ‘dmesg’, ‘netstat’, and so on will be familiar to Unix users since they display the result of the corresponding command (Sonos players run the Linux operating system internally).



Support Screen

The support screen is available at the following URL:


It will print one link per player, as well as one link for the controller and one for the network matrix.

Player Name 1 (RINCON_000E5812345671400)

Player Name n (RINCON_000E5876543211400)
Network Matrix

The information available under each player name is very similar to the one provided by the status screen of that particular player. I haven’t yet looked carefully into the Controller menu.

The last link, the network matrix, is extremely useful to diagnose wireless connectivity issues. It looks like this:

Sonos network matrix

Colors in the left column denote the ambient RF noise seen by the Sonos unit. Colored cells in the body of the matrix indicate the state and strength of the ‘tunnels’ across the mesh:

  • A gray cell means that the Sonos isn’t sending data wirelessly between the 2 units. This is expected if the 2 players are connected through a network cable, as the wired connection is typically more reliable and therefore preferred to a wifi path.
  • A green, yellow, or red cell indicate an active path. The actual color is used to encode the strength of the wireless signal.

OFDM signal levels go from 0 to 5, where 5 is best and 0 is way too low to get a reliable connection. Noise floors are typically in the [-80 -110] range, where -110 is considered excellent and -80 bad.

If a unit isn’t sending or receiving data wirelessly (i.e. the corresponding row and column in the matrix are both gray) the wireless adapter can be turned offto save power and reduce wireless interference.

Rebooting the player

Accessing the following URL will trigger an immediate reboot of the player:


Troubleshooting Network Connectivity

Sonos offer 3 traditional network debugging tools (ping, traceroute and nmblookup) from this URL:


Controling the WiFi network link

The WiFi link can be enabled or disabled through the wifictfl URL. If the WiFi is turned on, it will use different frequency channels based on the region in which the player was sold. For example, the use of channels 12 through 14 is not allowed in the United States. You can update this setting at the following URL:


HE tunnel gefixed

ipv6 test


Keanu Reeves writes…

“My friend’s mom has eaten healthy all her life. Never consumed alcohol or any “bad” food, exercised every day, very active, took all supplements, never went in the sun without sunscreen and for short periods, she pretty much protected her health. She is now 76 and has skin cancer, bone marrow cancer and extreme osteoporosis.

My friend’s father eats lots of bacon, butter, fat, never exercised, was out in the sun burnt to a crisp every summer, he basically took the approach to live life to his fullest. He is 81 and the doctors say his health is that of a young person.

People, you cannot hide from your poison. It’s out there and it will find you so in the words of my friend’s still living mother: “if I would have known my life would end this way I would have lived it more to the fullest enjoying everything I was told not to!”

None of us are getting out of here alive, so please stop treating yourself like an after thought. Eat the delicious food. Walk in the sunshine. Jump in the ocean. Say the truth that you’re carrying in your heart like hidden treasure. Be silly. Be kind. Be weird. There’s no time for anything else.”