speedtest-cli网络测速
speedtest-cli是speedtest.net提供的一个python工具,就于网络测速。而且其还可以通过将测试的结果以图片的方式展线出来。这里插点题外话,speedtest.net也提供在线测速——通过web进行测试,原理是在你的浏览器中加载JavaScript代码并自动检测离你最近的Speedtest.net服务器,然后向服务器发送HTTP GET and POST请求来测试上行/下行网速。
一、安装speedtest-cli
speedtest-cli是一个用Python编写的轻量级Linux命令行工具,在Python2.4至3.4版本下均可运行。它基于 Speedtest.net的基础架构来测量网络的上/下行速率。安装speedtest-cli很简单——只需要下载其Python脚本文件。
1$ wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
2$ chmod +x speedtest_cli.py
为该脚本增加可执行权限即可运行,如果想直接运行命令就可以执行的话,可以将其移到bin目录下即可。
二、speedtest-cli测试网速
1、不加任何参数直接执行
1yang@crunchbang:/tmp$ python speedtest_cli.py
2Retrieving speedtest.net configuration...
3Retrieving speedtest.net server list...
4Testing from WASU TV & Communication Holding Co.,Ltd. (58.100.45.111)...
5Selecting best server based on ping...
6Hosted by China Mobile Jiangsu Co., Ltd. (Suzhou) [124.58 km]: 17.722 ms
7Testing download speed........................................
8Download: 3.72 Mbit/s
9Testing upload speed..................................................
10Upload: 3.88 Mbit/s
是不是发现很强大,其检测出我的网络是华数网络,自动选择了离我主机最近位于江苏苏州的speedtest.net主机进行测试,并将我的网络的上下行结果进行输出。
2、将测试结果通过图片分享
1yang@crunchbang:/tmp$ python speedtest_cli.py --share
2Retrieving speedtest.net configuration...
3Retrieving speedtest.net server list...
4Testing from WASU TV & Communication Holding Co.,Ltd. (58.100.45.111)...
5Selecting best server based on ping...
6Hosted by China Telecom (Shanghai) [168.66 km]: 16.292 ms
7Testing download speed........................................
8Download: 3.06 Mbit/s
9Testing upload speed..................................................
10Upload: 1.65 Mbit/s
11Share results: http://www.speedtest.net/result/3358961164.png
其本输出和上面没什么区别,不过在最后多了一个图片的链接页面,图片内容如下:
3、列出speedtest.net的服务器(离距离远近的顺序)
1yang@crunchbang:/tmp$ python speedtest_cli.py --list|more
2Retrieving speedtest.net configuration...
3Retrieving speedtest.net server list...
43927) China Mobile Jiangsu Co., Ltd. (Suzhou, China) [124.58 km]
53633) China Telecom (Shanghai, China) [168.66 km]
64490) China Telecom Anhui Co.,Ltd (Wuhu, China) [203.24 km]
74377) China Mobile Group Anhui Co.,Ltd (Hefei, China) [320.21 km]
84433) China Telecom Anhui Co.,Ltd (Hefei, China) [320.21 km]
94543) China Mobile Group Fujian MCC Co. Ltd. (Fuzhou, China) [474.25 km]
103921) Taiwan Fixed Network (Taoyuan, Taiwan) [589.71 km]
112589) Far EasTone Telecommunications Co., Ltd (Taoyuan, Taiwan) [589.71 km]
123967) Chief Telecom (Taipei, Taiwan) [600.87 km]
132133) Taiwan Fixed Network (Taipei, Taiwan) [600.87 km]
142327) Far Eastone Telecommunications Co., Ltd. (Taipei, Taiwan) [600.87 km]
152181) kbro CO.LTD (Taipei, Taiwan) [600.87 km]
后面还有更多的服务器,这里省略了没列全。
4、选择服务器进行测速
1yang@crunchbang:/tmp$ python speedtest_cli.py --server 3633
2Retrieving speedtest.net configuration...
3Retrieving speedtest.net server list...
4Testing from WASU TV & Communication Holding Co.,Ltd. (58.100.45.111)...
5Hosted by China Telecom (Shanghai) [168.66 km]: 23.286 ms
6Testing download speed........................................
7Download: 3.47 Mbit/s
8Testing upload speed..................................................
9Upload: 3.67 Mbit/s
如上图所示,我选择了上海的服务器进行测试,后面的ID值就是我们用list参数查看的服务器的ID 。
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/speedtest-cli-test-network-speed/3094.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.