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: 375
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

Postby 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: 8
Joined: Wednesday 24 August 2016 15:25
Target OS: -
Domoticz version:
Contact:

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

Postby 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: 93
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

Postby 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: 6
Joined: Thursday 12 February 2015 7:59
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Postby 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 43 times
Speed.zip
Up- and download
(14.4 KiB) Downloaded 37 times

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

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

Postby 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: 93
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

Postby 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: 93
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

Postby 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: 8
Joined: Wednesday 24 August 2016 15:25
Target OS: -
Domoticz version:
Contact:

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

Postby 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: 93
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

Postby 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&hilit=windows#p100190

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

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

Postby 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

Postby 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 ?

sincze
Posts: 564
Joined: Monday 02 June 2014 22:46
Target OS: Linux
Domoticz version: 3.6179
Location: Netherlands
Contact:

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

Postby 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_icons_for_webinterface


Return to “Third party and supplementary tools”

Who is online

Users browsing this forum: No registered users and 1 guest