简体   繁体   English

不同界面上的 Speedtest-cli

[英]Speedtest-cli on a different interface

I have eth0, eth1 and wlan0 connected to my Raspberry Pi.我有 eth0、eth1 和 wlan0 连接到我的树莓派。 I would like to measure the internet speed of the different interface, in this case - eth1.我想测量不同接口的互联网速度,在这种情况下 - eth1。 It works well for eth0 (192.168.1.21), but I get an error if I try to use a different interface, in this case, eth1 (192.168.8.100).它适用于 eth0 (192.168.1.21),但如果我尝试使用不同的接口(在本例中为 eth1 (192.168.8.100)),我会收到错误消息。

I have read Speedtest python API documentation and mostly copied code from there.我已经阅读了 Speedtest python API 文档,并且大部分是从那里复制的代码。 I have also tried to search before posting on StackOverflow.在 StackOverflow 上发帖之前,我也尝试过搜索。

source = "192.168.8.100" #eth1
s = speedtest.Speedtest(source_address=source)
s.get_servers()
s.get_best_server()
s.download()
s.upload()
res = s.results.dict()
download = res["download"]
upload = res["upload"]
ping = round(res["ping"])
print(download, upload, ping)

EDIT: This is the error:编辑:这是错误:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/root/post_test2.py", line 11, in home
    s = speedtest.Speedtest(source_address=source)
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1091, in __init__
    self.get_config()
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1123, in get_config
    raise ConfigRetrievalError(e)
speedtest.ConfigRetrievalError: <urlopen error timed out>

I'm new to speedtest-cli and this post has answered my question on how to use a different interface.我是 speedtest-cli 的新手,这篇文章回答了我关于如何使用不同界面的问题。 So, thanks for that :-)所以,谢谢你:-)

It's a bit of a guess, but your problem might be due to network routing.这有点猜测,但您的问题可能是由于网络路由。 Can you ping an external host through both interfaces:您可以通过两个接口 ping 外部主机吗:

ping -I eth0 google.com
ping -I eth1 google.com

If eth1 times out, then you probably need to update your network routing entries.如果 eth1 超时,那么您可能需要更新您的网络路由条目。

ip route

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 speedtest-cli 在控制台中工作,但不能作为脚本使用 - speedtest-cli works in console, but not as script 更改 speedtest.py 和 speedtest-cli 的 output 以将 IP 地址包含在 output.Z628Z19675FFE88FEF3F 文件中 - Changing output of speedtest.py and speedtest-cli to include IP address in output .csv file 在 Python3 脚本中使用 speedtest-cli 来测量互联网速度 - 收到错误消息“No module named speedtest” - Using speedtest-cli within a Python3 script to measure internet speed - getting error message 'No module named speedtest' 创建一个python函数以在终端中运行speedtest-cli / ping并将结果输出到日志文件 - Create a python function to run speedtest-cli/ping in terminal and output result to a log file 我如何在python脚本中使用speedtest-cli或任何替代方法而不是命令行? - How do i use speedtest-cli or any alternative in python script instead of command line? 有没有办法在速度测试期间使用 Python 的 speedtest-cli 库实时绘制实时下载/上传速度? - Is there a way to graph the real-time download/upload speed real time during a speed test using the speedtest-cli library for Python? 在不同的命令行界面(CLI)中打开python程序? - Open python program within a different command-line-interface(CLI)? python 'speedtest' 没有属性 'Speedtest' - python 'speedtest' has no attribute 'Speedtest' 使用选择界面创建 Python CLI - Create Python CLI with select interface 通用python rpc和cli接口 - Common python rpc and cli interface
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM