How to monitor your internet connection with virtual custom sensors

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.
User avatar
safi78
Posts: 454
Joined: Thursday 05 September 2013 15:39
Target OS: Linux
Domoticz version: LastBeta
Location: Alkmaar, NL
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by safi78 » Friday 23 December 2016 11:15

I created a fairly similar script for a differtent purpose, maybe you guys like it as well: viewtopic.php?f=21&t=14591
I don't know if you noticed or not, but I'm an extremely arrogant man who tends to think all of his plans will work ...

https://safiweb.nl

homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz

johan99
Posts: 9
Joined: Wednesday 24 August 2016 15:25
Target OS: -
Domoticz version:
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by johan99 » Saturday 07 January 2017 11:46

Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.

But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax

Any idea on what I do wrong?

mikeoo
Posts: 114
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by mikeoo » Saturday 07 January 2017 11:59

johan99 wrote:Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.

But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax

Any idea on what I do wrong?
Place your script and the command you use also here so we can check.

User avatar
gjaa
Posts: 28
Joined: Thursday 12 February 2015 7:59
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by gjaa » Saturday 07 January 2017 18:55

I've made some icons (I don't like the default Icon ;) )
One for up and download (speed)
and one for ping (ping)
Attachments
ping.zip
ping
(19.61 KiB) Downloaded 91 times
Speed.zip
Up- and download
(14.4 KiB) Downloaded 78 times

johan99
Posts: 9
Joined: Wednesday 24 August 2016 15:25
Target OS: -
Domoticz version:
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by johan99 » Saturday 07 January 2017 22:26

mikeoo wrote:
johan99 wrote:Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.

But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax

Any idea on what I do wrong?
Place your script and the command you use also here so we can check.
Ok, here is first the code and after that is the command line.

Code: Select all

#!/bin/bash

#setup
port=8080
username=xxxx
password=xxxx
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&param=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$uploadidx&svalue=$upload"
command in windows (cmd runned in admin mode): python speedtest.sh

mikeoo
Posts: 114
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by mikeoo » Sunday 08 January 2017 9:40

johan99 wrote:
mikeoo wrote:
johan99 wrote:Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.

But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax

Any idea on what I do wrong?
Place your script and the command you use also here so we can check.
Ok, here is first the code and after that is the command line.

Code: Select all

#!/bin/bash

#setup
port=8080
username=xxxx
password=xxxx
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&param=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$uploadidx&svalue=$upload"
command in windows (cmd runned in admin mode): python speedtest.sh
Try to change host=localhost to host=ip-adres of domoticz and test if that change something.

mikeoo
Posts: 114
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by mikeoo » Sunday 08 January 2017 9:55

gjaa wrote:I've made some icons (I don't like the default Icon ;) )
One for up and download (speed)
and one for ping (ping)
Nice one's :mrgreen:

Tip
I did not see them when i try to change them for the Custum Sensor afther uploading the icons in Domoticz.
I reboot did not solve the problem.

You need the do a browser refresh and then you can see them.

johan99
Posts: 9
Joined: Wednesday 24 August 2016 15:25
Target OS: -
Domoticz version:
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by johan99 » Sunday 08 January 2017 17:59

mikeoo wrote:
johan99 wrote:
mikeoo wrote: Try to change host=localhost to host=ip-adres of domoticz and test if that change something.
When i use the IP I get this error:

File "speedtest2.sh", line 7
host=192.168.0.188
^
SyntaxError: invalid syntax

I says the zero in the adress is the problem, dont know why, the adress is correct. When I edit the file i use a Windows PC and notepad++ and choose unix EOL.

mikeoo
Posts: 114
Joined: Sunday 22 March 2015 8:35
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Holland
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by mikeoo » Monday 09 January 2017 8:31

johan99 wrote:
mikeoo wrote:
johan99 wrote:
When i use the IP I get this error:

File "speedtest2.sh", line 7
host=192.168.0.188
^
SyntaxError: invalid syntax

I says the zero in the adress is the problem, dont know why, the adress is correct. When I edit the file i use a Windows PC and notepad++ and choose unix EOL.
You can try the use a different editor. Lot of Windows editors give problems with linux files and to be sure try an other one. Because it say that er is a problem it looks like notepad++ does something with the file. Try Sublime Text https://sublimetext.com/3 that one is working fine with linux files

Create a new file again, don't copy and past the old one because then you can copy the strange characters in to the new file.

If it still not working maybe a pyhton version problem, try to run it without python command and just speedtest
viewtopic.php?f=21&t=13814&p=100190&hil ... ws#p100190

johan99
Posts: 9
Joined: Wednesday 24 August 2016 15:25
Target OS: -
Domoticz version:
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by johan99 » Tuesday 10 January 2017 12:39

I tried sublimetext now aswell and get the same issues.
I think I set a Raspberry Pi up (have one not used for anything) and use that for this instead. Using it as a 2:nd Domoticz server. When reading this forum I realize that most of you use RP and most guides are written for RP.

Thanks for the help though. And I'll keep on using the Windows server as my main server for Domoticz and are intrested to hear from you who got everything working fine with Win and Domoticz.

dtech
Posts: 22
Joined: Thursday 26 November 2015 9:31
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: RE: Re: How to monitor your internet connection with virtual custom sensors

Post by dtech » Thursday 26 January 2017 20:35

gjaa wrote:I've made some icons (I don't like the default Icon ;) )
One for up and download (speed)
and one for ping (ping)
How this icons can be added ?

User avatar
sincze
Posts: 667
Joined: Monday 02 June 2014 22:46
Target OS: Linux
Domoticz version: 3.7546
Location: Netherlands
Contact:

Re: RE: Re: How to monitor your internet connection with virtual custom sensors

Post by sincze » Thursday 26 January 2017 21:46

dtech wrote:
gjaa wrote:I've made some icons (I don't like the default Icon ;) )
One for up and download (speed)
and one for ping (ping)
How this icons can be added ?
I found the solution in the wiki
http://www.domoticz.com/wiki/Custom_ico ... binterface
Running Domoticz since 2013 with Cubietruck
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

Trigun
Posts: 154
Joined: Wednesday 30 November 2016 12:58
Target OS: Raspberry Pi
Domoticz version: 3.5877
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by Trigun » Sunday 16 April 2017 16:41

Hi all, first of all, great feature!! i carried out all the steps bit for some reason the custom sensors don't show the values. When I run the script I do get the correct info, but the sensors are not showing anything. Does anyone have an idea where I went wrong?


Sent from my iPhone using Tapatalk

User avatar
EdwinK
Posts: 646
Joined: Sunday 22 January 2017 22:46
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Rhoon - Netherlands
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by EdwinK » Sunday 16 April 2017 20:02

I like this script a lot. One small thing though.

After the data, I get a '0' instead of the right value (ms, Mbp/s). Can this be fixed?

Image
Forget about the first tile, that is from another script.
Running latest BETA on a NAS Synology 413j | Toon Thermostat | RFxcom | Dashticz V2 |

koowee
Posts: 59
Joined: Thursday 29 December 2016 19:17
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Finland
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by koowee » Sunday 16 April 2017 20:35

EdKo66 wrote:I like this script a lot. One small thing though.

After the data, I get a '0' instead of the right value (ms, Mbp/s). Can this be fixed?

Image
Forget about the first tile, that is from another script.
I think that you need to modify those, Device (Ping, Download and Upload) > Edit > Axis label (add ms or Mbp/s depending device)

User avatar
EdwinK
Posts: 646
Joined: Sunday 22 January 2017 22:46
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Rhoon - Netherlands
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by EdwinK » Sunday 16 April 2017 22:08

Ah.. Of course. Thanks :)
Running latest BETA on a NAS Synology 413j | Toon Thermostat | RFxcom | Dashticz V2 |

Trigun
Posts: 154
Joined: Wednesday 30 November 2016 12:58
Target OS: Raspberry Pi
Domoticz version: 3.5877
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by Trigun » Tuesday 18 April 2017 19:21

Hey guys,

Really like the script! its working well when manually run. but for some reason I can't seem to get the output in domoticz.
does anyone have an idea?
I am running it on a Synology NAS.

Thnx in advance!

User avatar
EdwinK
Posts: 646
Joined: Sunday 22 January 2017 22:46
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Rhoon - Netherlands
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by EdwinK » Tuesday 18 April 2017 19:54

Running this on a Synology NAS too, and had it working in matter of minutes.

Synology doesn't have apt-get, so you need to find another way to get the files. I used easy_install, but can't quite remember how I did install that.
Search for easy_install and Synology on the Google.
Last edited by EdwinK on Tuesday 18 April 2017 20:00, edited 1 time in total.
Running latest BETA on a NAS Synology 413j | Toon Thermostat | RFxcom | Dashticz V2 |

User avatar
EdwinK
Posts: 646
Joined: Sunday 22 January 2017 22:46
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Rhoon - Netherlands
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by EdwinK » Tuesday 18 April 2017 19:55

gjaa wrote:I've made some icons (I don't like the default Icon ;) )
One for up and download (speed)
and one for ping (ping)

Thanks for those icons ;)
Running latest BETA on a NAS Synology 413j | Toon Thermostat | RFxcom | Dashticz V2 |

Trigun
Posts: 154
Joined: Wednesday 30 November 2016 12:58
Target OS: Raspberry Pi
Domoticz version: 3.5877
Contact:

Re: How to monitor your internet connection with virtual custom sensors

Post by Trigun » Tuesday 18 April 2017 20:03

Hi Edko66,

is there a chance you can help me out here?
since I have no username and password for domoticz, this is my script.

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&param=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command&param=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command&param=udevice&idx=$uploadidx&svalue=$upload"
I can see the output.txt file it not in the same directory where thie stdomo.sh and speedtest-cli are in. shoudl this be?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests