> CentOS > CentOS入门 >

CentOS下使用命令行测试网速

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

下载speedtest-cli.py 并更改权限
# wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
# chmod a+rx speedtest_cli.py

使用speedtest-cli
# speedtest-cli
# 下方内容为回显内容(整个过程需要花上一点时间)
*****************************************************************
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from China Unicom ####### (0.0.0.0)...
Selecting best server based on ping...
Hosted by Vladlink (Vladivostok) [509.76 km]: 14.623 ms
Testing download speed........................................
Download: 2.10 Mbit/s
Testing upload speed..................................................
Upload: 0.41 Mbit/s
*****************************************************************

# speedtest-cli -h
usage: speedtest-cli [-h] [--share] [--simple] [--list] [--server SERVER]
                     [--mini MINI] [--source SOURCE] [--version]

Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------

https://github.com/sivel/speedtest-cli

optional arguments:
  -h, --help       show this help message and exit
  --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
  --version        Show the version number and exit



#如果想方便的使用speedtest-cli 可以对speedtest-cli.py进行如下操作
# sudo mv speedtest_cli.py /usr/local/bin/speedtest-cli
# sudo chown root:root /usr/local/bin/speedtest-cli




(责任编辑:IT)