Page 13 of 13

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

Posted: Tuesday 20 April 2021 20:22
by sundodger
Ah, i have to admit i do not know how to do that.
Off to google it.

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

Posted: Tuesday 20 April 2021 20:39
by Rolandet
Go to the directory where the script is located
run: sudo ./speedtest.sh

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

Posted: Thursday 29 April 2021 17:25
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

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

Posted: Thursday 29 April 2021 19:34
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

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

Posted: Thursday 29 April 2021 19:46
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

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

Posted: Thursday 29 April 2021 20:46
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

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

Posted: Thursday 29 April 2021 20:54
by meal
Hello,

Here is the piece of code
speedtest.png
speedtest.png (15.16 KiB) Viewed 2814 times
Best regards

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

Posted: Thursday 29 April 2021 22:22
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

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

Posted: Friday 30 April 2021 17:09
by meal
Hello
You will find attached the file.
Unzip it and copy it to the relevant location on your computer.
Best regards

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

Posted: Friday 30 April 2021 17:42
by Gravityz
@meal
working perfectly now. thanks for helping me and others out.

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

Posted: Tuesday 11 May 2021 19:59
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

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

Posted: Sunday 05 March 2023 14:04
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?

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

Posted: Sunday 05 March 2023 16:00
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.

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

Posted: Sunday 05 March 2023 19:27
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)

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

Posted: Monday 06 March 2023 13:16
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

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

Posted: Thursday 09 March 2023 21:12
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?

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

Posted: Saturday 30 December 2023 15:14
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.

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

Posted: Saturday 30 December 2023 15:34
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.