Linux上下行网速测试工具_speedtest-cli安装使用方法

2025-05-27 0 29

speedtest-cliLinux下的一个上下行网速测试工具,是一个用Python写的命令行脚本。

电脑测试网速这个功能估计大家都用过,但是服务器需要测试外网的速度相比大家做法各有不同,有的人使用自己的服务器来测试上下行速度,有些通过下载某个网站的资源来测试下行速度,鉴于这些节点比较少,而且测试麻烦,我向大家推荐speedtest-cli.
speedtest是一个使用python编写的命令行脚本,通过调用speedtest.net测试上下行的接口来完成速度测试.最后我会测试运维生存时间所在服务器的外网速度。

需要python2.4-3.3的支持。

项目地址:https://github.com/sivel/speedtest-cli

安装方式

安装方式有多种

1. 安装speedtest-cli
speedtest-cli需要在python 2.4-3.4的环境下,安装方法都很简单,自己选择以下最适合你的一种.
1.1 pip方式

# pip install speedtest-cli

1.2 easy_install方式

# easy_install speedtest-cli

1.3 github+pip方式

# pip install git+https://github.com/sivel/speedtest-cli.git

或者

?

1

2
# git clone https://github.com/sivel/speedtest-cli.git

# python speedtest-cli/setup.py install

1.4 下载脚本方式

?

1

2
# wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py

chmod +x speedtest-cli

或者

?

1

2
# curl -o speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py

chmod +x speedtest-cli

直接下载脚本,给予执行权限即可。

2. speedtest-cli用法

命令很简单,直接上帮助

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17
[root@li229-122 ~]# speedtest-cli --help

Usage: speedtest-cli [options]

Command line interface for testing internet bandwidth using speedtest.net.

--------------------------------------------------------------------------

https://github.com/sivel/speedtest-cli

Options:

-h, --help show this help message and exit

--share Generate and provide a URL to the speedtest.net share

results image

--simple Suppress verbose output, only show basic information

--list Display a list of speedtest.net servers sorted by distance

--server=SERVER Specify a server ID to test against

--mini=MINI URL of the Speedtest Mini server

--source=SOURCE Source IP address to bind to

--version Show the version number and exit

3. speedtest-cli常用命令详解

3.1 list
根据距离显示speedtest.net的测试服务器列表

3.2 server
指定列表中id的服务器来做测试
3.3 share
分享你的网速,该命令会在speedtest网站上生成网速测试结果的图片
4. speedtest-cli测试
4.1 列出所有在中国的测试服务器

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18
[root@li229-122 ~]# speedtest-cli --list | grep China

1185) China Unicom (Changchun, China) [10534.35 km]

3784) China Mobile (Urumqi, China) [10581.15 km]

2667) Beijing Normal University (Beijing, China) [11117.03 km]

2529) Beijing Normal University (Beijing, China) [11117.03 km]

2816) Capital Online Data Service (Beijing, China) [11117.03 km]

4354) SXmobile (Taiyuan, China) [11383.17 km]

3973) China Telecom (Lanzhou, China) [11615.43 km]

3633) China Telecom (Shanghai, China) [11983.37 km]

3927) China Mobile Jiangsu Co., Ltd. (Suzhou, China) [11989.27 km]

2461) China Unicom (Chengdu, China) [12213.35 km]

1028) Shepherd Software (Xiamen, China) [12785.57 km]

1628) Xiamen Guangdian Xinxu (Xiamen, China) [12785.57 km]

3891) GZinternet (Guangzhou, China) [13005.36 km]

3871) SZWCDMA (Shenzhen, China) [13059.20 km]

3819) SZU (Shenzhen, China) [13059.20 km]

1536) STC (Hong Kong, China) [13088.37 km]

1890) Telin (Hong Kong, China) [13088.37 km]

结果解释
3633) China Telecom (Shanghai, China) [11983.37 km]
3633: 服务器id
china telecom:isp,这里是中国电信
shanghai,china :服务器所在地址
11983.37 km:两台服务器地理位置之间距离,我这台机器在美国,和上海相距11983.37公里,很远呐.

4.1 外网速度测试
咱们运维生存时间的服务器在美国linode,我测试到上海这台机器的速度,并且生成图片报告

?

1

2

3

4

5

6

7

8

9

10
[root@li229-122 ~]# speedtest-cli --server=3633 --share

Retrieving speedtest.net configuration...

Retrieving speedtest.net server list...

Testing from Linode (173.255.219.122)...

Hosted by China Telecom (Shanghai) [11983.37 km]: 23.603 ms

Testing download speed........................................

Download: 24.84 Mbit/s

Testing upload speed..................................................

Upload: 4.57 Mbit/s

Share results: http://www.speedtest.net/result/3240988007.png

通过结果可以看到,上海电信用户访问www.ttlsa.com可以达到4.57mbit,上传到www.ttlsa.com可以达到28.84mbit/s. share参数的效果图如下:

Linux上下行网速测试工具_speedtest-cli安装使用方法

speedtest-cli

5 参考地址

项目地址:https://github.com/sivel/speedtest-cli

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 Linux上下行网速测试工具_speedtest-cli安装使用方法 https://www.kuaiidc.com/60689.html

相关文章

发表评论
暂无评论