测试网络带宽的命令行界面

测试网络带宽的命令行界面

参考github地址:https://github.com/sivel/speedtest-cli

一、安装speedtest-cli

speedtest-cli是一个用Python编写的轻量级Linux命令行工具,在Python2.4至3.4版本下均可运行。它基于Speedtest.net的基础架构来测量网络的上/下行速率。安装speedtest-cli很简单——只需要下载其Python脚本文件。网上的教程非常古老,用了只会报过期脚本 ,更新如下

1
2
3
4
5
6
7
8
9
wget https://github.com/sivel/speedtest-cli/blob/master/speedtest.py

chmod a+rx speedtest.py

mv speedtest.py /usr/local/bin/speedtest-cli

chown root:root /usr/local/bin/speedtest-cli

speedtest-cli

二、使用speedtest-cli测试网速

使用speedtest-cli命令也很简单,它不需要任何参数即可工作。

1
[root@localhost temp]# speedtest-cli

输入这个命令后,它会自动发现离你最近的Speedtest.net服务器(地理距离),然后打印出测试的网络上/下行速率。

1
2
3
4
5
6
7
8
9
10
[root@localhost temp]# speedtest-cli 
Retrieving speedtest.net configuration… 
Retrieving speedtest.net server list… 
Testing from China Telecom (219.135.214.145)… 
Selecting best server based on latency… 
Hosted by CTM Internet Services (Macau) [106.48 km]: 55.974 ms 
Testing download speed…………………………………. 
Download: 3.15 Mbit/s 
Testing upload speed………………………………………….. 
Upload: 0.58 Mbit/s

测试结果说明:上行为 0.58Mbit/s 下行为 3.15 Mbit/s