Linux命令行测试网速


很多时候我们需要测试Linux服务器的上行和下行宽带。在可用于测试宽带速度的网站中,Speedtest.net也许是使用最广泛的应用“之一”。
Speedtest.net提供了一个命令行版本——speedtest-cli。下面将向你演示如何在Linux的命令行中使用speedtest-cli来测试宽带连接速度。

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

[root@localhost temp]# wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
[root@localhost temp]# chmod a+rx speedtest_cli.py
[root@localhost temp]# mv speedtest_cli.py /usr/local/bin/speedtest-cli
[root@localhost temp]# chown root:root /usr/local/bin/speedtest-cli

也可以在自己电脑上下载好 speedtest_cli.py 然后上传到服务器上。

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

[root@localhost temp]# speedtest-cli

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

[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
当然对于测试结果,一般在实际应用中不一定能达到这个值,仅作为参考使用。

相关内容

    暂无相关文章