大家都知道在speedtest是市面上最准确最全面的测速工具,但在linux命令行不能直接使用,所以我们就借助脚本调用speedtest的接口来利用他测试网速。
1.下载speedtest-cli脚本:
下载地址:https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
2.把脚本移动到/usr/local/bin/下面并重命名为speedtest-cli
mv speedtest_cli.py /usr/local/bin/speedtest-cli
3.给脚本赋予权限
cd /usr/local/bin
chmod a+rx speedtest-cli
chown root:root speedtest-cli
4.执行命令speedtest-cli测试网速
[[email protected] ~]# speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from China Telecom (219.135.56.21)...
Selecting best server based on ping...
Hosted by CTM Internet Services (Macau) [106.48 km]: 25.352 ms
Testing download speed........................................
Download: 3.80 Mbits/s
Testing upload speed..................................................
Upload: 3.79 Mbits/s