How to monitor your internet connection with virtual custom sensors
Moderator: leecollings
-
- Posts: 54
- Joined: Thursday 18 August 2016 10:06
- Target OS: Linux
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi,
I tested the script and when i start it it works fine. But when starting the script in cron, nothing happens. I can see the output.tx file is being updated but the info in the html page of domoticz is not updated. Also starting with sudo in cron doesn't help.
Does anyone know why ?
I tested the script and when i start it it works fine. But when starting the script in cron, nothing happens. I can see the output.tx file is being updated but the info in the html page of domoticz is not updated. Also starting with sudo in cron doesn't help.
Does anyone know why ?
Ubuntu server, Raspberry Pi, PiFace 2, RFXCom, Z-wave Stick, Kaku, Sensor
-
- 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
Too bad....mikeoo wrote:
You could try my speedtest-cli file i use on the Synology. Maybe the problem is with the file itself.
https://www.wetransfer.com/downloads/b3 ... 654/5737ae
Thanks for your help!
Code: Select all
root@DiskStation:/volume1/@appstore/domoticz/var/scripts# python speedtest-cli.py
Traceback (most recent call last):
File "speedtest-cli.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
Try running it my way. You run in with Python command.lukev wrote:Too bad....mikeoo wrote:
You could try my speedtest-cli file i use on the Synology. Maybe the problem is with the file itself.
https://www.wetransfer.com/downloads/b3 ... 654/5737ae
Thanks for your help!
Code: Select all
root@DiskStation:/volume1/@appstore/domoticz/var/scripts# python speedtest-cli.py Traceback (most recent call last): File "speedtest-cli.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
You only need two files in the folder (st2domo.sh and speedtest-cli)
Did you test it with the scripts i placed here.
viewtopic.php?f=21&t=13814&start=60#p103936
Then run sh /<path>/st2domo.sh and not with the python command.
-
- 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
Still overflowing... driving me nuts...
Yesterday I even uninstalled my SickRage and Couchpotato to be able to uninstall and re-install the SynoCommunity Python package.
No luck on that end, only a lot of work....
Code: Select all
root@DiskStation:/volume1/@appstore/domoticz/var/scripts# sh st2domo.sh
Traceback (most recent call last):
File "/volume1/@appstore/domoticz/var/scripts/speedtest-cli", 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
ping = ms
download = Mbps
upload = Mbps
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "ERR"
}
No luck on that end, only a lot of work....
-
- 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
Update:
I have installed python2.7 via ipkg, because I read the overflow problem was linked to python2.5.
Because python2.5 is a part of my firmware, I now have 2 versions installed.
So I edited speedtest-cli, the first line now reads:
instead of:
Problem solved.... at last!
I have installed python2.7 via ipkg, because I read the overflow problem was linked to python2.5.
Because python2.5 is a part of my firmware, I now have 2 versions installed.
So I edited speedtest-cli, the first line now reads:
Code: Select all
#!/usr/bin/python2.7
Code: Select all
#!/usr/bin/env python
-
- 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
Great solutionslukev wrote:Update:
I have installed python2.7 via ipkg, because I read the overflow problem was linked to python2.5.
Because python2.5 is a part of my firmware, I now have 2 versions installed.
So I edited speedtest-cli, the first line now reads:
instead of:Code: Select all
#!/usr/bin/python2.7
Problem solved.... at last!Code: Select all
#!/usr/bin/env python
-
- Posts: 12
- Joined: Tuesday 02 February 2016 11:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Denmark
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
+1gennapium wrote:Hi,
I tested the script and when i start it it works fine. But when starting the script in cron, nothing happens. I can see the output.tx file is being updated but the info in the html page of domoticz is not updated. Also starting with sudo in cron doesn't help.
Does anyone know why ?
-
- Posts: 54
- Joined: Thursday 18 August 2016 10:06
- Target OS: Linux
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
In linux give the command echo $PATH and copy the result. In the script at the beginning enter:
PATH=PATH:(the result from echo PATH)
That did the trick for me.
Good luck.
PATH=PATH:(the result from echo PATH)
That did the trick for me.
Good luck.
Ubuntu server, Raspberry Pi, PiFace 2, RFXCom, Z-wave Stick, Kaku, Sensor
-
- Posts: 12
- Joined: Tuesday 02 February 2016 11:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Denmark
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Perfect - works like a charmgennapium wrote:In linux give the command echo $PATH and copy the result. In the script at the beginning enter:
PATH=PATH:(the result from echo PATH)
That did the trick for me.
Good luck.
Thanks.
-
- Posts: 60
- Joined: Saturday 20 June 2015 10:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
the same for me the script works fine but not the crontab, any idea ?gennapium wrote:Hi,
I tested the script and when i start it it works fine. But when starting the script in cron, nothing happens. I can see the output.tx file is being updated but the info in the html page of domoticz is not updated. Also starting with sudo in cron doesn't help.
Does anyone know why ?
-
- 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
One solution could be to replace spaces with TAB key.bran2000 wrote:the same for me the script works fine but not the crontab, any idea ?gennapium wrote:Hi,
I tested the script and when i start it it works fine. But when starting the script in cron, nothing happens. I can see the output.tx file is being updated but the info in the html page of domoticz is not updated. Also starting with sudo in cron doesn't help.
Does anyone know why ?
For Synology for example you need to use a TAB between every character and NOT spaces.
My rule as example:
Code: Select all
*/30 * * * * root sh /volume2/@appstore/speedtest/st2domo.sh
Code: Select all
*/30[tab]*[tab]*[tab]*[tab*[tab]root[tab]sh /volume2/@appstore/speedtest/st2domo.sh
Remove all spaces and replace them with a tab.
Save the cronjob and don't forget to restart the cronjob!!!!!
I that is not working
Check the logfiles. Mabye you can find an error there.
Don't know what system you use but on most linux systems you can find it in: /var/log
-
- Posts: 60
- Joined: Saturday 20 June 2015 10:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Thanks for your answer but i have other tasks and they work fine. i'll try with tab key between every character.
when you said "don't forget to restart the cronjob" it means restart the crontab, i did this : sudo /etc/init.d/cron restart
For your information, i have a raspberry pi.
when you said "don't forget to restart the cronjob" it means restart the crontab, i did this : sudo /etc/init.d/cron restart
For your information, i have a raspberry pi.
-
- 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
Correct. You can also.restart the rasp. For.rasp you can use spaces.bran2000 wrote:Thanks for your answer but i have other tasks and they work fine. i'll try with tab key between every character.
when you said "don't forget to restart the cronjob" it means restart the crontab, i did this : sudo /etc/init.d/cron restart
For your information, i have a raspberry pi.
Try also.user root in the cronjob line
-
- Posts: 54
- Joined: Thursday 18 August 2016 10:06
- Target OS: Linux
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Did you add the path to the script as i wrote in this topic ? I think that is the problem.
Ubuntu server, Raspberry Pi, PiFace 2, RFXCom, Z-wave Stick, Kaku, Sensor
-
- Posts: 60
- Joined: Saturday 20 June 2015 10:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
it's not working.
when you said "Try also.user root in the cronjob line" you mean run the crontab with the root account ?
when you said "Try also.user root in the cronjob line" you mean run the crontab with the root account ?
-
- Posts: 60
- Joined: Saturday 20 June 2015 10:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
this is the line in my crontab :
*/1 * * * * /home/pi/domoticz/scripts/speedtestdomo.sh
*/1 * * * * /home/pi/domoticz/scripts/speedtestdomo.sh
-
- Posts: 60
- Joined: Saturday 20 June 2015 10:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
i tried also as root not working too.
- phoenixblue
- Posts: 76
- Joined: Friday 25 November 2016 11:20
- Target OS: Windows
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi,
Maybe an strange question, this is my first script i want to run on an Raspberry Pi but i think i have somewhere forget something.
I have use the script but when i want manual run it i get the following error's:
What can be the problem?
Maybe an strange question, this is my first script i want to run on an Raspberry Pi but i think i have somewhere forget something.
I have use the script but when i want manual run it i get the following error's:
Code: Select all
pi@Domoticz:~/domoticz/scripts $ sh st2domo.sh
: not found 2: st2domo.sh:
: not found 12: st2domo.sh:
: not found 15: st2domo.sh:
: not found 16: st2domo.sh:
: not found 19: st2domo.sh:
cat: outst.txt: Bestand of map bestaat niet
cat: outst.txt: Bestand of map bestaat niet
cat: outst.txt: Bestand of map bestaat niet
: not found 23: st2domo.sh:
: not found 24: st2domo.sh:
Mbpsoad =
Mbpsd =▒
msg =▒
: not found 29: st2domo.sh:
: not found 30: st2domo.sh:
st2domo.sh: 33: st2domo.sh: Syntax error: Bad fd number
-
- 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
Did do adjust the script to your system. Ip - Passwoord - IDX etc.phoenixblue wrote:Hi,
Maybe an strange question, this is my first script i want to run on an Raspberry Pi but i think i have somewhere forget something.
I have use the script but when i want manual run it i get the following error's:
What can be the problem?Code: Select all
pi@Domoticz:~/domoticz/scripts $ sh st2domo.sh : not found 2: st2domo.sh: : not found 12: st2domo.sh: : not found 15: st2domo.sh: : not found 16: st2domo.sh: : not found 19: st2domo.sh: cat: outst.txt: Bestand of map bestaat niet cat: outst.txt: Bestand of map bestaat niet cat: outst.txt: Bestand of map bestaat niet : not found 23: st2domo.sh: : not found 24: st2domo.sh: Mbpsoad = Mbpsd =▒ msg =▒ : not found 29: st2domo.sh: : not found 30: st2domo.sh: st2domo.sh: 33: st2domo.sh: Syntax error: Bad fd number
Did you create st2domo.sh maby with notepad of wordpad. That can give problems with strange characters added when saving the file.
Place your script so we can see what you use.
- phoenixblue
- Posts: 76
- Joined: Friday 25 November 2016 11:20
- Target OS: Windows
- Domoticz version:
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi,
I use this script:
I have made the sh file in windows with notepad++ and upload it with ftp to the rasp.
When I check the file with for example nano editor in SSH i see no strange characters.
I use this script:
Code: Select all
#!/bin/bash
#setup
host=192.168.10.137
port=8080
username=mijn gebruikersnaam
password=mijn password
pingidx=27
downloadidx=28
uploadidx=29
# 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"
When I check the file with for example nano editor in SSH i see no strange characters.
Who is online
Users browsing this forum: No registered users and 0 guests