How to monitor your internet connection with virtual custom sensors
Moderator: leecollings
-
- Posts: 129
- Joined: Saturday 01 October 2016 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: LastBeta
- Location: Italy BG
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
thanks safi78, but, if i take the same test with the wired lan on rpi, and disable the adapter usb/wireless, what's happened ? i think the download must increase, or not ?
Master (pi3) - MB sensors + Dummy + Sysfs gpio + 1 NodOn MSP-3 + 1 Aeotec DSB28 Energy Meter + 3 Danfoss RS Room + 7 Danfoss Z Thermostat + 1 Swiid Inter + 9 FGS222
Slave01 (pi2) - MB sensors + Dummy + Weather Underground + 2 FGS223 + 1 FGWPE/F
Slave01 (pi2) - MB sensors + Dummy + Weather Underground + 2 FGS223 + 1 FGWPE/F
-
- Posts: 204
- Joined: Thursday 05 September 2013 15:39
- Target OS: Linux
- Domoticz version: LastBeta
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
That's probably true, if the RPI shares it's general throughput with the USB-stuff, I'd say yes. If it doesn't have to share, it has more for the ethernet-stuff.
But hey, why run it on your pi if that's unreliable? Run it on a machine that can handle your 10/1Mbps for good test results?
It's easy to change the API/URL-stuff in the script, so 'where' you run it doesn't really matter 
Put linux on your coffee-maker or fridge, run the test from there if these are equipped with better hardware?
But hey, why run it on your pi if that's unreliable? Run it on a machine that can handle your 10/1Mbps for good test results?


Put linux on your coffee-maker or fridge, run the test from there if these are equipped with better hardware?

homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 129
- Joined: Saturday 01 October 2016 14:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: LastBeta
- Location: Italy BG
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
yes of course, but i don't understand if your result in the screenshot on the top of the post arrived from rpi or another machine. if arrived from rpi, why you have so much download speed ?????
Master (pi3) - MB sensors + Dummy + Sysfs gpio + 1 NodOn MSP-3 + 1 Aeotec DSB28 Energy Meter + 3 Danfoss RS Room + 7 Danfoss Z Thermostat + 1 Swiid Inter + 9 FGS222
Slave01 (pi2) - MB sensors + Dummy + Weather Underground + 2 FGS223 + 1 FGWPE/F
Slave01 (pi2) - MB sensors + Dummy + Weather Underground + 2 FGS223 + 1 FGWPE/F
-
- Posts: 204
- Joined: Thursday 05 September 2013 15:39
- Target OS: Linux
- Domoticz version: LastBeta
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
The results of the screenshots are from an 8-core MacMini, 16Gb RAM and an SSD running Debian Linux (not that it's relevant). I left the RPI-hardware for Domoticz a long time ago because:

- It's slow (in every way: througput, SSH, running apt-get update annoyed the hell outta me, even switching stuff in my home improved drastically with better hardware).
It's unreliable (power failures / disk corruption);
It's unreliable (power needs to be in some kind of Goldy-Locks-zone if you add more stuff);
It's unreliable (it was broken more then it was running the way I wanted);
It doesn't have enough ports for all the stuff I want;
I don't want to run my home on unreliable stuff.

Last edited by safi78 on Thursday 03 November 2016 19:22, edited 2 times in total.
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 204
- Joined: Thursday 05 September 2013 15:39
- Target OS: Linux
- Domoticz version: LastBeta
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I do have a Pi though 
I use it for the USB P1 Smartmeter (which will influence my test) and running domoticz (idem) and running this test (ditto)
I believe it's 2nd gen, model B:
shitty results with Pi:
proper results with MacMini:
So ping is ~2x better, same as download. Upload is within the probably 25Mbps it can handle, so about the same.
Interesting read about Mbps's, Pi and models: http://www.jeffgeerling.com/blogs/jeff- ... networking

I use it for the USB P1 Smartmeter (which will influence my test) and running domoticz (idem) and running this test (ditto)

I believe it's 2nd gen, model B:
shitty results with Pi:
Code: Select all
Ping: 44.949 ms
Download: 26.80 Mbits/s
Upload: 4.76 Mbits/s
Code: Select all
Ping: 24.766 ms
Download: 50.63 Mbit/s
Upload: 4.49 Mbit/s
Interesting read about Mbps's, Pi and models: http://www.jeffgeerling.com/blogs/jeff- ... networking
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: monitor internet connection with virtual sensors
How in the world did you do that? Can't find it anywhere.....mikeoo wrote:
I then installed (speedtest-cli) on my Synology NAS DS214+ and run the script from the NAS with 1Gb network connection but ping keeps high.

- jumbotroll
- Posts: 793
- Joined: Tuesday 13 January 2015 14:36
- Target OS: NAS (Synology & others)
- Domoticz version: Beta
- Location: Oslo,Norway
- Contact:
Re: monitor internet connection with virtual sensors
Install Python spk first and then log in to your NAS with Telnet or SSH and type: sudo pip install speedtest-clilukev wrote:How in the world did you do that? Can't find it anywhere.....mikeoo wrote:
I then installed (speedtest-cli) on my Synology NAS DS214+ and run the script from the NAS with 1Gb network connection but ping keeps high.
If you like the work I do for synology and domoticz, I appreciate a donation.
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: monitor internet connection with virtual sensors
I did install python 2.7.11-15 (from Synocommunity) and sudo also (via ipkGui), but it's not working:jumbotroll wrote:
Install Python spk first and then log in to your NAS with Telnet or SSH and type: sudo pip install speedtest-cli
Code: Select all
root@DiskStation:~# sudo pip install speedtest-cli
sudo: pip: command not found
- jumbotroll
- Posts: 793
- Joined: Tuesday 13 January 2015 14:36
- Target OS: NAS (Synology & others)
- Domoticz version: Beta
- Location: Oslo,Norway
- Contact:
Re: monitor internet connection with virtual sensors
Ok, you must first install pip.lukev wrote:I did install python 2.7.11-15 (from Synocommunity) and sudo also (via ipkGui), but it's not working:jumbotroll wrote:
Install Python spk first and then log in to your NAS with Telnet or SSH and type: sudo pip install speedtest-cli
Any thoughts?Code: Select all
root@DiskStation:~# sudo pip install speedtest-cli sudo: pip: command not found
Try to type: sudo easy_install pip
If you like the work I do for synology and domoticz, I appreciate a donation.
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Code: Select all
root@DiskStation:~# sudo easy_install pip
sudo: easy_install: command not found
root@DiskStation:~#

Code: Select all
root@DiskStation:~# sudo
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u
user name|#uid] file ...
- jumbotroll
- Posts: 793
- Joined: Tuesday 13 January 2015 14:36
- Target OS: NAS (Synology & others)
- Domoticz version: Beta
- Location: Oslo,Norway
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I don't remember what I didlukev wrote:Code: Select all
root@DiskStation:~# sudo easy_install pip sudo: easy_install: command not found root@DiskStation:~#

If you like the work I do for synology and domoticz, I appreciate a donation.
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Also tried this one: https://github.com/sivel/speedtest-cli
But then again... didn't work...
But then again... didn't work...
Code: Select all
root@DiskStation:~# python speedtest-cli/setup.py install
running install
Traceback (most recent call last):
File "speedtest-cli/setup.py", line 91, in <module>
'Programming Language :: Python :: 3.4',
File "/opt/lib/python2.5/distutils/core.py", line 151, in setup
dist.run_commands()
File "/opt/lib/python2.5/distutils/dist.py", line 974, in run_commands
self.run_command(cmd)
File "/opt/lib/python2.5/distutils/dist.py", line 994, in run_command
cmd_obj.run()
File "/opt/lib/python2.5/site-packages/setuptools/command/install.py", line 76, in run
self.do_egg_install()
File "/opt/lib/python2.5/site-packages/setuptools/command/install.py", line 85, in do_egg_install
easy_install = self.distribution.get_command_class('easy_install')
File "/opt/lib/python2.5/site-packages/setuptools/dist.py", line 395, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File "/opt/lib/python2.5/site-packages/pkg_resources.py", line 1954, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/opt/lib/python2.5/site-packages/setuptools/command/easy_install.py", line 12, in <module>
import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random
File "/opt/lib/python2.5/tempfile.py", line 33, in <module>
from random import Random as _Random
File "/opt/lib/python2.5/random.py", line 58, in <module>
SG_MAGICCONST = 1.0 + _log(4.5)
OverflowError: math range error
root@DiskStation:~#
- jumbotroll
- Posts: 793
- Joined: Tuesday 13 January 2015 14:36
- Target OS: NAS (Synology & others)
- Domoticz version: Beta
- Location: Oslo,Norway
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Found this: https://forum.synology.com/enu/viewtopic.php?t=59837
Solution:
download https://raw.github.com/pypa/pip/master/ ... get-pip.py
run:
ds>python get-pip.py
run:
DS> sudo pip install speedtest-cli
done
Solution:
download https://raw.github.com/pypa/pip/master/ ... get-pip.py
run:
ds>python get-pip.py
run:
DS> sudo pip install speedtest-cli
done
If you like the work I do for synology and domoticz, I appreciate a donation.
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
https://paypal.me/Jumbotroll
Regards
Jumbotroll
http://www.jadahl.com
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Thanks Jumbotroll, but that also is a no-go.... The link to get-pip.py is old. It refers to a new link, which... of course ... doesn't work.
But I have managed to install it an other way, but still get a Overflow error... I think I will call it a day for now...
But I have managed to install it an other way, but still get a Overflow error... I think I will call it a day for now...
Code: Select all
root@DiskStation:/volume1/@appstore/domoticz/var/scripts# python speedtest.py
Traceback (most recent call last):
File "speedtest.py", line 51, in <module>
from urllib2 import urlopen, Request, HTTPError, URLError
File "/opt/lib/python2.5/urllib2.py", line 92, in <module>
import httplib
File "/opt/lib/python2.5/httplib.py", line 70, in <module>
import mimetools
File "/opt/lib/python2.5/mimetools.py", line 6, in <module>
import tempfile
File "/opt/lib/python2.5/tempfile.py", line 33, in <module>
from random import Random as _Random
File "/opt/lib/python2.5/random.py", line 58, in <module>
SG_MAGICCONST = 1.0 + _log(4.5)
OverflowError: math range error
-
- Posts: 110
- Joined: Sunday 22 March 2015 7:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Holland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
@lukev
What i did
I did not install anything extra. But i could be the in the past i already install some package.
1. Create a folder on the NAS /volume2/@appstore/speedtest and put speedtest-cli in it. Any other folder would be fine also.
2. Create in the same folder st2domo.sh and put the code in it. The code you find a bit lower.
Adjust the lines with Setup to your situation and change the IDX to the right ones for you and choose a Speedtest server near you.
Run in Putty: /volume2/@appstore/speedtest/speedtest-cli --list i take the upper one.
3, Both files give permission 0755
4. chmod +x st2domo.sh and I also did this for the speedtest-cli file.
code st2domo.sh
Edit the cronjob on the Synology (/var/crontab)
Put in this file (i run it every 30 min)
Restart the Cronjob. For DSM 5 you can use.
Or restart your NAS
For testing you can run the script in Putty (Synology)
sh /volume2/@appstore/speedtest/st2domo.sh
Done.
What i did
I did not install anything extra. But i could be the in the past i already install some package.
1. Create a folder on the NAS /volume2/@appstore/speedtest and put speedtest-cli in it. Any other folder would be fine also.
2. Create in the same folder st2domo.sh and put the code in it. The code you find a bit lower.
Adjust the lines with Setup to your situation and change the IDX to the right ones for you and choose a Speedtest server near you.
Run in Putty: /volume2/@appstore/speedtest/speedtest-cli --list i take the upper one.
3, Both files give permission 0755
4. chmod +x st2domo.sh and I also did this for the speedtest-cli file.
code st2domo.sh
Code: Select all
#!/bin/bash
#setup
host=ip-adres
port=8080
username=username
password=password
pingidx=990
downloadidx=991
uploadidx=992
# speedtest server number
serverst=2042
# no need to edit
/volume2/@appstore/speedtest/speedtest-cli --simple --server $serverst > output.txt
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
download=$(cat output.txt | sed -ne 's/^Download: \([0-9]*\.[0-9]*\).*/\1/p')
upload=$(cat output.txt | sed -ne 's/^Upload: \([0-9]*\.[0-9]*\).*/\1/p')
#output if you run it manually
echo "ping = $ping ms"
echo "download = $download Mbps"
echo "upload = $upload Mbps"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
Put in this file (i run it every 30 min)
Code: Select all
*/30 * * * * root sh /volume2/@appstore/speedtest/st2domo.sh
Code: Select all
/usr/syno/sbin/synoservicectl --restart crond
For testing you can run the script in Putty (Synology)
sh /volume2/@appstore/speedtest/st2domo.sh
Done.
Last edited by mikeoo on Tuesday 15 November 2016 7:30, edited 1 time in total.
-
- Posts: 204
- Joined: Thursday 05 September 2013 15:39
- Target OS: Linux
- Domoticz version: LastBeta
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Nice.
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Thanks for all your help, but the Speedtest script is just overflowing for some strange reason. I think it has something to do with my setup
-
- Posts: 110
- Joined: Sunday 22 March 2015 7:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Holland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
You could try my speedtest-cli file i use on the Synology. Maybe the problem is with the file itself.lukev wrote:Thanks for all your help, but the Speedtest script is just overflowing for some strange reason. I think it has something to do with my setup
https://www.wetransfer.com/downloads/b3 ... 654/5737ae
link is working until 21/11/2016
-
- Posts: 66
- Joined: Friday 21 October 2016 10:42
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Thanks, gonna try tonight!!
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I've made few changes to the original script to have the possibility to run the test several times per day more, have the possibility to run "ondemand"
Here's my new script which works quite good!!
It's all based on user variables (I don't really like virtual switches) and it works like having into a variable all the hours you want to run, another variable specify the minute, the third is for show debug info in the log
I'm not so skilled in LUA so I don't know if this would be the best way to reaching the result (I know... a vitual switch with a script and timers would probably be better because you can setup times you want... but .... I don't like virtual switches... they meks me confusing!
)
the fromCSV funzion move the hour string variable to a table
Here's my new script which works quite good!!
It's all based on user variables (I don't really like virtual switches) and it works like having into a variable all the hours you want to run, another variable specify the minute, the third is for show debug info in the log
I'm not so skilled in LUA so I don't know if this would be the best way to reaching the result (I know... a vitual switch with a script and timers would probably be better because you can setup times you want... but .... I don't like virtual switches... they meks me confusing!

the fromCSV funzion move the hour string variable to a table
Code: Select all
debugger = tonumber(uservariables['SpeedTest_Debug'])
JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- File per la decodifica del tracciato JSON restituito dallo speedtest
cTime = os.date("*t")
scName = '/home/pi/domoticz/scripts/speedtest-json.sh'
stForce = tonumber(uservariables['SpeedTest_Run']) -- Flag per SpeedTest forzato
runScript = false -- Semaforo per esecuzione Procedura
runMinute = tonumber(uservariables['SpeedTest_RunMinute']) -- Minutaggio di esecuzione
prxPrint = '>>> [ST] >>> ' -- Prefisso per stringhe di debug
--
-- INIZIO PROCEDURA PER CONVERSIONE STRINGA CSV IN TABELLA
--
function fromCSV (s)
s = s .. ',' -- ending comma
local t = {} -- table to collect fields
local fieldstart = 1
repeat
-- next field is quoted? (start with `"'?)
if string.find(s, '^"', fieldstart) then
local a, c
local i = fieldstart
repeat
-- find closing quote
a, i, c = string.find(s, '"("?)', i+1)
until c ~= '"' -- quote not followed by quote?
if not i then error('unmatched "') end
local f = string.sub(s, fieldstart+1, i-1)
table.insert(t, (string.gsub(f, '""', '"')))
fieldstart = string.find(s, ',', i) + 1
else -- unquoted; find next comma
local nexti = string.find(s, ',', fieldstart)
table.insert(t, string.sub(s, fieldstart, nexti-1))
fieldstart = nexti + 1
end
until fieldstart > string.len(s)
return t
end
--
-- FINE PROCEDURA PER CONVERSIONE STRINGA CSV IN TABELLA
--
commandArray = {}
-- Creazione array orari di esecuzione
arrRunOnTime = fromCSV(uservariables['SpeedTest_RunOnTime'])
-- Valutazione della variabile di esecuzione script obbligata
if stForce == 1 then
print(prxPrint..'SpeedTest forzato')
runScript = true
commandArray["Variable:SpeedTest_Run"] = tostring(0)
end
-- Valutazione orario (minuti e ore)
for i,runHour in pairs(arrRunOnTime) do
-- Debugging
if debugger == 1 then
print (prxPrint..'Orario reale/schedulato/forzato: '..cTime.hour..':'..cTime.min..'/'..runHour..':'..runMinute..'/'..stForce)
end
if tonumber(cTime.min) == tonumber(runMinute) then
if tonumber(runHour) == tonumber(cTime.hour) then
runScript = true
print(prxPrint..'SpeedTest Schedulato')
end
end
end
-- Debugging
if debugger == 1 then
print (prxPrint..'Semafori forzato/Esecuzione: '..stForce..'/'..tostring(runScript))
end
-- Script Principale
if runScript == true then
print(prxPrint..'Esecuzione SpeedTest')
os.execute(scriptPath)
file = io.open("/home/pi/domoticz/scripts/speed-test.json", "r")
json_text = file:read()
speeds = JSON:decode(json_text)
print(prxPrint..'['..cTime.hour..':'..cTime.min..'] >>> Dl/Ul/Pg: '..speeds.Download_Mbit..'/'..speeds.Upload_Mbit..'/'..speeds.Ping_ms)
commandArray[1]={['UpdateDevice']='147|0|'..speeds.Download_Mbit}
commandArray[2]={['UpdateDevice']='148|0|'..speeds.Upload_Mbit}
commandArray[3]={['UpdateDevice']='146|0|'..speeds.Ping_ms}
os.execute("rm /home/pi/domoticz/scripts/speed-test.json")
end
return commandArray
- Attachments
-
- variables list
- Cattura-1.jpg (10.13 KiB) Viewed 4484 times
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
Who is online
Users browsing this forum: No registered users and 1 guest