Chinaunix首页 | 论坛 | 博客
  • 博客访问: 786170
  • 博文数量: 179
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1536
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-27 11:05
个人简介

MySQL工程师 QQ:1815357042

文章分类

全部博文(179)

文章存档

2015年(179)

分类: LINUX

2015-03-12 14:34:40

转载自:

Speedtest.net提供了一个命令行工具 speedtest-cli
我们可以在Linux中使用speedtest-cli来测试宽带速度
speedtest-cli是由Python编写的轻量级Linux命令行工具基于Speedtest.net的基础架构来测量网络的上/下行速率
运行环境:Python2.4-3.4

github:

下载一个speedtest-cli.py 文件并更改权限
  1. [root@steven ~]# wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
  2. --2015-03-12 14:01:40-- https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
  3. Resolving raw.github.com... 103.245.222.133
  4. Connecting to raw.github.com|103.245.222.133|:443... connected.
  5. HTTP request sent, awaiting response... 301 Moved Permanently
  6. Location: https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py [following]
  7. --2015-03-12 14:01:42-- https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
  8. Resolving raw.githubusercontent.com... 103.245.222.133
  9. Connecting to raw.githubusercontent.com|103.245.222.133|:443... connected.
  10. HTTP request sent, awaiting response... 200 OK
  11. Length: 24314 (24K) [text/plain]
  12. Saving to: “speedtest_cli.py”


  13. 100%[=================================>] 24,314 78.5K/s in 0.3s

  14. 2015-03-12 14:01:44 (78.5 KB/s) - “speedtest_cli.py” saved [24314/24314]
  1. [root@steven ~]# du -sh speedtest_cli.py
  2. 24K    speedtest_cli.py
改权限
  1. [root@steven ~]# chmod a+rx speedtest_cli.py

直接执行
  1. [root@steven ~]# ./speedtest_cli.py
  2. Retrieving speedtest.net configuration...
  3. Retrieving speedtest.net server list...
  4. Testing from China Telecom Guangdong (183.63.158.150)...
  5. Selecting best server based on latency...
  6. Hosted by Unicom-GZ (Guangzhou) [2.51 km]: 7.517 ms
  7. Testing download speed........................................
  8. Download: 1.41 Mbit/s
  9. Testing upload speed..................................................
  10. Upload: 1.49 Mbit/s

获取帮助
  1. [root@steven ~]# ./speedtest_cli.py -h
  2. Usage: speedtest_cli.py [options]

  3. Command line interface for testing internet bandwidth using speedtest.net.
  4. --------------------------------------------------------------------------
  5. https://github.com/sivel/speedtest-cli

  6. Options:
  7.   -h, --help show this help message and exit
  8.   --bytes Display values in bytes instead of bits. Does not affect
  9.                      the image generated by --share
  10.   --share Generate and provide a URL to the speedtest.net share
  11.                      results image
  12.   --simple Suppress verbose output, only show basic information
  13.   --list Display a list of speedtest.net servers sorted by
  14.                      distance
  15.   --server=SERVER Specify a server ID to test against
  16.   --mini=MINI URL of the Speedtest Mini server
  17.   --source=SOURCE Source IP address to bind to
  18.   --timeout=TIMEOUT HTTP timeout in seconds. Default 10
  19.   --version Show the version number and exit

如果想方便的使用speedtest-cli 可以对speedtest-cli.py进行如下操作
剪切到/usr/local/bin/目录下,并改名为speedtest-cli
  1. sudo mv speedtest_cli.py /usr/local/bin/speedtest-cli
如果下载的时候不是用root身份下载这个文件的,那么需要sudo执行命令 并且改变属主和属组
  1. sudo chown -R root:root /usr/local/bin/speedtest-cli

直接执行
  1. [root@steven ~]# speedtest-cli
  2. Retrieving speedtest.net configuration...
  3. Retrieving speedtest.net server list...
  4. Testing from China Telecom Guangdong (183.63.158.150)...
  5. Selecting best server based on latency...
  6. Hosted by Unicom-GZ (Guangzhou) [2.51 km]: 7.052 ms
  7. Testing download speed........................................
  8. Download: 1.49 Mbit/s
  9. Testing upload speed..................................................
  10. Upload: 1.50 Mbit/s


阅读(2749) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~