speedtest-cli顾名思义,这个命令为网络测速命令,基于Python编写,测试系统网络的上传下载速度,GitHub托管的项目地址,以下列出常见的用法安装命令pip install speedtest-cli
查看帮助,具体选项说明自行查看,这里列出几个常用的打印全球的测速服务器,结果可能会非常多,可以重定向到文件保存,方便查看;或者只打印中国的测速服务器speedtest-cli --list | grep -i 'china' > servers.txt
[root@localhost.localdomain ~]# speedtest-cli --list | grep -i 'China' > servers.txt
[root@localhost.localdomain ~]# cat servers.txt
36663) China Telecom JiangSu 5G (Zhenjiang, China) [887.61 km]
30852) Duke Kunshan University (Kunshan, China) [1053.72 km]
24447) China Unicom 5G (Shanghai, China) [1103.20 km]
36663) ChinaTelecomJiangSu5G (Zhenjiang, China) [887.61 km]
# 6663是测速服务器ID,
ChinaTelecomJiangSu5G (Zhenjiang, China)
# 中国江苏电信5G。
887.61km
# 服务器距离本机887.61公里
30852) DukeKunshanUniversity (Kunshan, China) [1053.72 km]
24447) ChinaUnicom5G (Shanghai, China) [1103.20 km]
# 指定某个测速服务器
speedtest-cli --server 36663
# 简化打印信息
speedtest-cli --server 36663 --simple
# 该命令默契情况下会选择最近距离的测速服务器作为测速
[root@localhost.localdomain ~]# curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
[root@localhost.localdomain ~]# curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
Retrieving speedtest.net configuration...
Testing from China Telecom (223.11.75.180)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by JSQY - Suzhou (Suzhou) [1034.70 km]: 41.943 ms
Testing download speed................................................................................
Download: 2.23 Mbit/s
Testing upload speed......................................................................................................
Upload: 6.55 Mbit/s
需要注意,执行过程可能会超时,那么就分两步执行,下载测速脚本,用Python执行,和命令行用法一样,也可以加执行参数