How to monitor your internet connection with virtual custom sensors
Moderator: leecollings
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi Edko66,
Ok, I got the last part working. but still othing happens within domoticz.
I the domoticz logfile it doesn't seem check on the script for some reason.
is there anything else I need to setup within domoticz besides creating 3 virtual devices?
I installed it through the following.
wget -O speedtest-cli https://raw.githubusercontent.com/sivel ... est_cli.py
within the CLI it works fine but somehow domoticz is seeing the output
Ok, I got the last part working. but still othing happens within domoticz.
I the domoticz logfile it doesn't seem check on the script for some reason.
is there anything else I need to setup within domoticz besides creating 3 virtual devices?
I installed it through the following.
wget -O speedtest-cli https://raw.githubusercontent.com/sivel ... est_cli.py
within the CLI it works fine but somehow domoticz is seeing the output
-
- 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
Hi Trigun,
What's the output of the script if you run it manually?
Looks like it looses the location to output.txt.
Specifying that output.txt should be at ~/ and later cat'ing it from there might do the trick
Also, your speedtest package seems to be in the admin folder. Did you schedule this in the crontab for admin as well? Or another user (that might not have permissions on that folder?)
Can you try this? I hope that with the '~' it will place the output.txt to the home-folder of the user you schedule it for, so it wouldn't matter which user you use. Next to that it's more specific to where the output.txt is, might work ...
What's the output of the script if you run it manually?
Looks like it looses the location to output.txt.
Specifying that output.txt should be at ~/ and later cat'ing it from there might do the trick
Also, your speedtest package seems to be in the admin folder. Did you schedule this in the crontab for admin as well? Or another user (that might not have permissions on that folder?)
Can you try this? I hope that with the '~' it will place the output.txt to the home-folder of the user you schedule it for, so it wouldn't matter which user you use. Next to that it's more specific to where the output.txt is, might work ...
Code: Select all
#!/bin/bash
#setup
host=192.168.10.21
port=8084
pingidx=8
downloadidx=6
uploadidx=7
# no need to edit
/volume1/homes/admin/Speedtest/speedtest-cli --server 5302 > ~/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://$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
- Siewert308SW
- Posts: 288
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Just wanna say thx for your script.
Using it to monitor some issues with my connection -> isp regarding ping times.
Using it to monitor some issues with my connection -> isp regarding ping times.
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- 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 to be appreciatedSiewert308SW wrote:Just wanna say thx for your script.
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi safi78,safi78 wrote:Hi Trigun,
What's the output of the script if you run it manually?
Looks like it looses the location to output.txt.
Specifying that output.txt should be at ~/ and later cat'ing it from there might do the trick
Also, your speedtest package seems to be in the admin folder. Did you schedule this in the crontab for admin as well? Or another user (that might not have permissions on that folder?)
Can you try this? I hope that with the '~' it will place the output.txt to the home-folder of the user you schedule it for, so it wouldn't matter which user you use. Next to that it's more specific to where the output.txt is, might work ...
Code: Select all
#!/bin/bash #setup host=192.168.10.21 port=8084 pingidx=8 downloadidx=6 uploadidx=7 # no need to edit /volume1/homes/admin/Speedtest/speedtest-cli --server 5302 > ~/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://$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping" curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download" curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
thnx for you reply!
It perfectly generates an output.txt file in the folder, the data is correct when I compare it to the output in de CLI but for some reason Domoticz is not picking up the values. I have no idea why it isn't working.
Grtz.
-
- 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
Again,
What's the output of the script if you run it manually?
Are you sure your host, port and idx settings are correct? And that you can connect without a password?
What's the output of the script if you run it manually?
Are you sure your host, port and idx settings are correct? And that you can connect without a password?
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
ok, this is what I do.safi78 wrote:Again,
What's the output of the script if you run it manually?
Are you sure your host, port and idx settings are correct? And that you can connect without a password?
I connect to the CLI run the following command: /volume1/homes/admin/Speedtest/stdomo.sh (without a password)
I get the following result: It takes long though for the script to finish, even though the results are already in the script.
+ even though there is no ping time, it does show a ping value in the output.txt file, I guess this is due to the fixed server I selected (5302)
I tried using the script you send in the previous reply, but so far no luck.
Grtz.
-
- 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
Can you try again without the '-s' after the 'curl' command?
As far as i can tell, you don't get a ping value (could be another version of speedtest-cli than I use).
And, curl returns it's result after trying to update domoticz, I don't see that here. (could be another version of curl).
Run it again, without the -s and send the results?
As far as i can tell, you don't get a ping value (could be another version of speedtest-cli than I use).
And, curl returns it's result after trying to update domoticz, I don't see that here. (could be another version of curl).
Run it again, without the -s and send the results?
Last edited by safi78 on Wednesday 19 April 2017 21:38, edited 1 time in total.
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
did it.
the result in the output.txt file is as follows: the output from the cli is as follows: it cold very well be I got the wrong version.
perhaps you can tell me which one I need for a synology NAS.
do I perhaps need to install a specific version of curl?
Cheers
the result in the output.txt file is as follows: the output from the cli is as follows: it cold very well be I got the wrong version.
perhaps you can tell me which one I need for a synology NAS.
do I perhaps need to install a specific version of curl?
Cheers
-
- 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
change
to
Code: Select all
/volume1/homes/admin/Speedtest/speedtest-cli --server 5302 > ~/output.txt
Code: Select all
/volume1/homes/admin/Speedtest/speedtest-cli --simple --server 5302 > ~/output.txt
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I got a ping value now
see: but stil no result in Domoticz.
Grtz
see: but stil no result in Domoticz.
Grtz
-
- 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
change
to
and show what happens.
Code: Select all
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
Code: Select all
curl -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping"
curl -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download"
curl -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I don't know what happend, but i re-installed speedtest-cli and re-did the script using your update ~/ and it works!
thanks a lot safi78. much appreciated!!
thanks a lot safi78. much appreciated!!
-
- 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 doubt if that was your problem, after adding the '--simple' the part to 'get' the data out of the txt was fixed already.Trigun wrote:I don't know what happend, but i re-installed speedtest-cli and re-did the script using your update ~/ and it works!
thanks a lot safi78. much appreciated!!
The problem was in your host/user/pass/idx and curl part, you probably changed something there.
Anyway, always glad to help!
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
-
- Posts: 31
- Joined: Friday 24 February 2017 12:01
- Target OS: Windows
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Here's the problem!
On windows 10,with CMD!
Someone help me?
On windows 10,with CMD!
Someone help me?
-
- Posts: 147
- Joined: Thursday 13 August 2015 13:36
- Target OS: NAS (Synology & others)
- Domoticz version: beta
- Location: Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
If you provide your script also we could hopefully see where the mistake (typo) is. Now we only know it is in line 14ilpier wrote:Here's the problem!
On windows 10,with CMD!
Someone help me?
Prob.JPG
Best regards Bert
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
-
- Posts: 31
- Joined: Friday 24 February 2017 12:01
- Target OS: Windows
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
yes Sorry!
here's the code!
here's the code!
Code: Select all
#!/bin/bash
#setup
port=8080
username=Admin
password=***
host=localhost
pingidx=239
downloadidx=241
uploadidx=240
# no need to edit
speedtest-cli --simple > 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"
-
- Posts: 543
- Joined: Saturday 02 July 2016 5:17
- Target OS: Linux
- Domoticz version: Beta
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
We need a combined sensor for Internet Upload and Download, like we have combined sensor for Temperature and Humidity, I have about 300 devices in my Domoticz, keeping them as organised as possible is essential!
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
-
- Posts: 147
- Joined: Thursday 13 August 2015 13:36
- Target OS: NAS (Synology & others)
- Domoticz version: beta
- Location: Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi ilpier,
I think your problem is related to the fact that your windows system doesn't know where to find the several files.
Your speedtest.sh is at C:\Users\andre\Desktop and you run the script from folder C:\Users\andre
But where will the system find speedtest-cli and where should it write output.txt?
That is why in Linux you use something like:
/volume1/homes/admin/Speedtest/speedtest-cli --simple --server 5302 > ~/output.txt
Here it is obvious. The speedtest-cli is at location: /volume1/homes/admin/Speedtest/
The output.txt file is written in ~/ which means in Linux the user directory of the user who is running this script.
I suggest that you put the script speedtest.sh in the same folder as where you put the speedtest-cli and run the script from that location.
Lets see what happens but most likely you will have results.
Good luck.
I think your problem is related to the fact that your windows system doesn't know where to find the several files.
Your speedtest.sh is at C:\Users\andre\Desktop and you run the script from folder C:\Users\andre
But where will the system find speedtest-cli and where should it write output.txt?
That is why in Linux you use something like:
/volume1/homes/admin/Speedtest/speedtest-cli --simple --server 5302 > ~/output.txt
Here it is obvious. The speedtest-cli is at location: /volume1/homes/admin/Speedtest/
The output.txt file is written in ~/ which means in Linux the user directory of the user who is running this script.
I suggest that you put the script speedtest.sh in the same folder as where you put the speedtest-cli and run the script from that location.
Lets see what happens but most likely you will have results.
Good luck.
Best regards Bert
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
-
- Posts: 31
- Joined: Friday 24 February 2017 12:01
- Target OS: Windows
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Thx @bertbidb,yes,i put .sh in the same folder of speedtest-cli and now,in the same folder i have output.txt with Ping,Download and Upload!
but in Domoticz nothing happen!
but in Domoticz nothing happen!
Who is online
Users browsing this forum: Google [Bot] and 0 guests