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.

Moderator: leecollings

sundodger
Posts: 29
Joined: Sunday 11 August 2019 17:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by sundodger »

Ah, i have to admit i do not know how to do that.
Off to google it.
User avatar
Rolandet
Posts: 95
Joined: Thursday 31 January 2019 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: The Netherlands
Contact:

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

Post by Rolandet »

Go to the directory where the script is located
run: sudo ./speedtest.sh
Custodes Septentrionum
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

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

Post by Gravityz »

does this also work from docker

i am getting this error

Code: Select all

root@domoticz:/opt/domoticz/userdata/scripts# ./speedtest.sh                                                                                                   
Traceback (most recent call last):                                                                                                                             
  File "/usr/bin/speedtest-cli", line 11, in <module>                                                                                                          
    load_entry_point('speedtest-cli==2.0.2', 'console_scripts', 'speedtest-cli')()                                                                             
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1887, in main                                                                                       
    shell()                                                                                                                                                    
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1783, in shell                                                                                      
    secure=args.secure                                                                                                                                         
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1027, in __init__                                                                                   
    self.get_config()                                                                                                                                          
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1113, in get_config                                                                                 
    map(int, server_config['ignoreids'].split(','))                                                                                                            
ValueError: invalid literal for int() with base 10: ''                                                                                                         
ping =  ms                                                                                                                                                     
download =  Mbps                                                                                                                                               
upload =   Mbps
meal
Posts: 107
Joined: Monday 04 March 2019 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: France
Contact:

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

Post by meal »

Hello,

To tackle the issue I change the line 1112
ignore_servers = list(
map(int, server_config['ignoreids'].split(','))
)

and replaced it by:

ignore_servers = []
if server_config['ignoreids']!="":
ignore_servers = list(
map(int, server_config['ignoreids'].split(','))
)
This prevents the exception

Hoping it works for you too.

Best regards
meal
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

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

Post by Gravityz »

tried it but it generates more errors

root@domoticz:/usr/lib/python3/dist-packages# speedtest-cli
Traceback (most recent call last):
File "/usr/bin/speedtest-cli", line 11, in <module>
load_entry_point('speedtest-cli==2.0.2', 'console_scripts', 'speedtest-cli')()
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 474, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2846, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2450, in load
return self.resolve()
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/__init__.py", line 2456, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/speedtest.py", line 1114
ignore_servers = list(
^
IndentationError: expected an indented block
root@domoticz:/usr/lib/python3/dist-packages# ^C
meal
Posts: 107
Joined: Monday 04 March 2019 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: France
Contact:

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

Post by meal »

Hello,

You have to replace the spaces by tabs to avoid the indentation problem.

I am using the text editor Notepad++ (in the Edit menu you will find the way to transform spaces by tabs).

Best regards
meal
meal
Posts: 107
Joined: Monday 04 March 2019 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: France
Contact:

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

Post by meal »

Hello,

Here is the piece of code
speedtest.png
speedtest.png (15.16 KiB) Viewed 2810 times
Best regards
meal
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

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

Post by Gravityz »

tried it again without luck. maybee drop your speedtest.py

another question, this thread is 13 pages long. why on earth is this problem not solved in the source
meal
Posts: 107
Joined: Monday 04 March 2019 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: France
Contact:

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

Post by meal »

Hello
You will find attached the file.
Unzip it and copy it to the relevant location on your computer.
Best regards
Attachments
speedtest.zip
(14.19 KiB) Downloaded 134 times
meal
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

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

Post by Gravityz »

@meal
working perfectly now. thanks for helping me and others out.
User avatar
Rolandet
Posts: 95
Joined: Thursday 31 January 2019 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: The Netherlands
Contact:

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

Post by Rolandet »

Anyone getting errors in this script?
Mine reports back error.

ValueError: invalid literal for int() with base 10: ''



The solution:
Run this command

Code: Select all

sudo wget https://raw.githubusercontent.com/sivel/speedtest-cli/v2.1.3/speedtest.py \
 -O /usr/lib/python3/dist-packages/speedtest.py/
Be sure to change the location of your dist-packages/speedtest.py to the python version you're using


Source of this solution
Custodes Septentrionum
User avatar
Rolandet
Posts: 95
Joined: Thursday 31 January 2019 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: The Netherlands
Contact:

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

Post by Rolandet »

Unfortunately I'm getting the same error constantly since Feb 14th

Code: Select all

<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html;charset=UTF-8
Access-Control-Allow-Origin: *
Set-Cookie: DMZSID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT
Does anyone have a solution or alternative?
Custodes Septentrionum
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

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

Post by manjh »

I did not pay attention to this for a while, it was measuring the speed on a daily basis but has suddenly stopped.
When I run on the console, I get this:

Code: Select all

Traceback (most recent call last):
  File "/usr/bin/speedtest-cli", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              3260, in <module>
    def _initialize_master_working_set():
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              3234, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              3272, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              581, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              909, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              795, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'speedtest-cli==2.0.2' distribution was                                                                                                              not found and is required by the application

What happened? How can I fix this?

Additional info: the logfile in which the values are stored, shows a last entry on February 9th... I have no idea what happened on that day.
Hans
User avatar
Rolandet
Posts: 95
Joined: Thursday 31 January 2019 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: The Netherlands
Contact:

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

Post by Rolandet »

manjh wrote: Sunday 05 March 2023 16:00 I did not pay attention to this for a while, it was measuring the speed on a daily basis but has suddenly stopped.
When I run on the console, I get this:

Code: Select all

Traceback (most recent call last):
  File "/usr/bin/speedtest-cli", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              3260, in <module>
    def _initialize_master_working_set():
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              3234, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              3272, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              581, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              909, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line                                                                                                              795, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'speedtest-cli==2.0.2' distribution was                                                                                                              not found and is required by the application

What happened? How can I fix this?

Additional info: the logfile in which the values are stored, shows a last entry on February 9th... I have no idea what happened on that day.
See the previous responses above mine (4 up)
Custodes Septentrionum
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

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

Post by manjh »

I ran this command:

Code: Select all

sudo wget https://raw.githubusercontent.com/sivel/speedtest-cli/v2.1.3/speedtest.py \
>  -O /usr/lib/python3/dist-packages/speedtest.py/
/usr/lib/python3/dist-packages/speedtest.py/: Is a directory
I then removed the last slash, and it runs.
But still speedtest-c;i throws an error;

Code: Select all

DistributionNotFound: The 'speedtest-cli==2.0.2' distribution was not found and is required by the application
Hans
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

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

Post by manjh »

manjh wrote: Monday 06 March 2023 13:16 I ran this command:

Code: Select all

sudo wget https://raw.githubusercontent.com/sivel/speedtest-cli/v2.1.3/speedtest.py \
>  -O /usr/lib/python3/dist-packages/speedtest.py/
/usr/lib/python3/dist-packages/speedtest.py/: Is a directory
I then removed the last slash, and it runs.
But still speedtest-c;i throws an error;

Code: Select all

DistributionNotFound: The 'speedtest-cli==2.0.2' distribution was not found and is required by the application
Any ideas, anyone?
Hans
benedict
Posts: 16
Joined: Thursday 16 December 2021 16:05
Target OS: Linux
Domoticz version:
Contact:

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

Post by benedict »

This repeated speedtesting is just abhorently wasteful. Not just for your own usage limit and bandwidth during testing, but also for the internet as a whole. Especially since what you want to achieve with it, is precisely why it's getting slow(er) than it could be.
As someone who's employed at a mobile operator (now mostly double 4G and prime 5G connectivity maintenance in towers and such..) I get to hear a lot of complaints from the sysadmins at the dc and core network and backbone operations, the constant speedtests and checks for speed are becoming a serious contender for the first spot on the total traffic generated globally charts. It's absurd, especially in this day and age. It's literally abusing energy, both locally as well as along the routers in between as well as on the server's side. It's like keeping a fossil fueled engine running in front of your house every day for a few hours, just to know that it works when you need to use it for something, completely disregarding its environmental effects. Please, if you can, stop using speedtesting to check if your internet is up or not. It's absurd.
User avatar
Rolandet
Posts: 95
Joined: Thursday 31 January 2019 21:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: The Netherlands
Contact:

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

Post by Rolandet »

A speedtest is nothing more then a little upload and download chunk. If that messes with your connection, you have way bigger problems.
Custodes Septentrionum
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest