Internet speed measurement, Speedtest-cli in Docker container

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
mojso
Posts: 86
Joined: Friday 08 November 2019 23:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Internet speed measurement, Speedtest-cli in Docker container

Post by mojso »

Internet speed measurement, Speedtest-cli in Docker container, script modification from this link
https://www.domoticz.com/wiki/Bash_-_S ... onitoring

and Internet Speed Test in a Container from here
https://github.com/robinmanuelthiel/sp ... e-ov-file

Code: Select all

#!/bin/bash
## This script was created by mojso
## https://github.com/mojso/Domoticz_scripts
#setup
host='localhost'
#idx for download, upload and ping
idxdl=1519
idxul=1520
idxpng=1521
idxbb=1522

# speedtest server number
# serverst=yyyy

# no need to edit
# speedtest-cli --simple --server $serverst > outst.txt
#speedtest-cli --simple > speedtest.txt
docker run --rm robinmanuelthiel/speedtest:latest > speedtest.txt

download=$(cat speedtest.txt | sed -n 's/.*download speed is \([0-9]*\) Mbps.*/\1/p')
upload=$(cat speedtest.txt | sed -n 's/.*upload speed is \([0-9]*\) Mbps.*/\1/p')
png=$(cat speedtest.txt | sed -n 's/Your ping is \(.*\) ms\./\1/p')

# output if you run it manually
echo "Download = $download Mbps"
echo "Upload =  $upload Mbps"
echo "Ping =  $png ms"

# Updating download, upload and ping ..
wget -q --delete-after "http://$host/json.htm?type=command&param=udevice&idx=$idxdl&svalue=$download" >/dev/null 2>&1
wget -q --delete-after "http://$host/json.htm?type=command&param=udevice&idx=$idxul&svalue=$upload" >/dev/null 2>&1
wget -q --delete-after "http://$host/json.htm?type=command&param=udevice&idx=$idxpng&svalue=$png" >/dev/null 2>&1

# Reset Broadband switch
wget -q --delete-after "http://$host/json.htm?type=command&param=udevice&idx=$idxbb&svalue=0" >/dev/null 2>&1

# Domoticz logging
wget -q --delete-after "http://$host/json.htm?type=command&param=addlogmessage&message=speedtest.net-logging" >/dev/null 2>&1





maybe it will be useful for someone
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest