转载自:
Speedtest.net提供了一个命令行工具 speedtest-cli
我们可以在Linux中使用speedtest-cli来测试宽带速度
speedtest-cli是由Python编写的轻量级Linux命令行工具基于Speedtest.net的基础架构来测量网络的上/下行速率
运行环境:Python2.4-3.4
github:
下载一个speedtest-cli.py 文件并更改权限
-
[root@steven ~]# wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
-
--2015-03-12 14:01:40-- https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
-
Resolving raw.github.com... 103.245.222.133
-
Connecting to raw.github.com|103.245.222.133|:443... connected.
-
HTTP request sent, awaiting response... 301 Moved Permanently
-
Location: https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py [following]
-
--2015-03-12 14:01:42-- https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
-
Resolving raw.githubusercontent.com... 103.245.222.133
-
Connecting to raw.githubusercontent.com|103.245.222.133|:443... connected.
-
HTTP request sent, awaiting response... 200 OK
-
Length: 24314 (24K) [text/plain]
-
Saving to: “speedtest_cli.py”
-
-
-
100%[=================================>] 24,314 78.5K/s in 0.3s
-
-
2015-03-12 14:01:44 (78.5 KB/s) - “speedtest_cli.py” saved [24314/24314]
-
[root@steven ~]# du -sh speedtest_cli.py
-
24K speedtest_cli.py
改权限
-
[root@steven ~]# chmod a+rx speedtest_cli.py
直接执行
-
[root@steven ~]# ./speedtest_cli.py
-
Retrieving speedtest.net configuration...
-
Retrieving speedtest.net server list...
-
Testing from China Telecom Guangdong (183.63.158.150)...
-
Selecting best server based on latency...
-
Hosted by Unicom-GZ (Guangzhou) [2.51 km]: 7.517 ms
-
Testing download speed........................................
-
Download: 1.41 Mbit/s
-
Testing upload speed..................................................
-
Upload: 1.49 Mbit/s
获取帮助
-
[root@steven ~]# ./speedtest_cli.py -h
-
Usage: speedtest_cli.py [options]
-
-
Command line interface for testing internet bandwidth using speedtest.net.
-
--------------------------------------------------------------------------
-
https://github.com/sivel/speedtest-cli
-
-
Options:
-
-h, --help show this help message and exit
-
--bytes Display values in bytes instead of bits. Does not affect
-
the image generated by --share
-
--share Generate and provide a URL to the speedtest.net share
-
results image
-
--simple Suppress verbose output, only show basic information
-
--list Display a list of speedtest.net servers sorted by
-
distance
-
--server=SERVER Specify a server ID to test against
-
--mini=MINI URL of the Speedtest Mini server
-
--source=SOURCE Source IP address to bind to
-
--timeout=TIMEOUT HTTP timeout in seconds. Default 10
-
--version Show the version number and exit
如果想方便的使用speedtest-cli 可以对speedtest-cli.py进行如下操作
剪切到
/usr/local/bin/目录下,并改名为speedtest-cli
-
sudo mv speedtest_cli.py /usr/local/bin/speedtest-cli
如果下载的时候不是用root身份下载这个文件的,那么需要sudo执行命令 并且改变属主和属组
-
sudo chown -R root:root /usr/local/bin/speedtest-cli
直接执行
-
[root@steven ~]# speedtest-cli
-
Retrieving speedtest.net configuration...
-
Retrieving speedtest.net server list...
-
Testing from China Telecom Guangdong (183.63.158.150)...
-
Selecting best server based on latency...
-
Hosted by Unicom-GZ (Guangzhou) [2.51 km]: 7.052 ms
-
Testing download speed........................................
-
Download: 1.49 Mbit/s
-
Testing upload speed..................................................
-
Upload: 1.50 Mbit/s
阅读(2978) | 评论(0) | 转发(0) |