DomoticaBoard

Scripts => Bash => Synology => Topic gestart door: Joost op 28 juli 2020, 11:12:25

Titel: Speedtest uitvoeren op Synology en weergeven in Domoticz
Bericht door: Joost op 28 juli 2020, 11:12:25
Met onderstaand script krijg je de waardes van upload- / downloadsnelheid en ping in Domoticz te zien.

Installeer eerst de python module speedtest-cli op de Synology NAS via de terminal:



sudo wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
sudo chmod +x speedtest-cli


Stappen:

#!/bin/bash

#setup
host='192.168.2.62:8080'
#idx for download, upload and ping
idxdl=154
idxul=155
idxpng=156

# speedtest server number
# serverst=xxxx

# no need to edit
# speedtest-cli --simple --server $serverst > outst.txt
/volume1/scripts/speedtest/speedtest-cli --simple > speedtest.txt

download=$(cat speedtest.txt | sed -ne 's/^Download: \([0-9]*\.[0-9]*\).*/\1/p')
upload=$(cat speedtest.txt | sed -ne 's/^Upload: \([0-9]*\.[0-9]*\).*/\1/p')
png=$(cat speedtest.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\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

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