speedtest-cli命令测试服务器外网速度
Tags: speedtest-cli测速网络
简介
电脑测试网速这个功能估计大家都用过,但是服务器需要测试外网的速度相比大家做法各有不同,有的人使用自己的服务器来测试上下行速度,有些通过下载某个网站的资源来测试下行速度,鉴于这些节点比较少,而且测试麻烦,我向大家推荐speedtest-cli
.
在windows下可以直接打开浏览器,访问 https://www.speedtest.cn/ ,进行测速即可:
在linux下,可以用speedtest-cli
。speedtest是一个使用python编写的命令行脚本,通过调用speedtest.net测试上下行的接口来完成速度测试.最后我会测试运维生存时间所在服务器的外网速度。
github:https://github.com/sivel/speedtest-cli
安装
yum
1 | yum install -y speedtest-cli |
pip / easy_install
1 | pip install speedtest-cli |
or
1 | easy_install speedtest-cli |
Github
1 | pip install git+https://github.com/sivel/speedtest-cli.git |
or
1 2 3 | git clone https://github.com/sivel/speedtest-cli.git cd speedtest-cli python setup.py install |
Just download (Like the way it used to be)
1 2 | wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py chmod +x speedtest-cli |
or
1 2 | curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py chmod +x speedtest-cli |
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | $ speedtest-cli -h usage: speedtest-cli [-h] [--no-download] [--no-upload] [--single] [--bytes] [--share] [--simple] [--csv] [--csv-delimiter CSV_DELIMITER] [--csv-header] [--json] [--list] [--server SERVER] [--exclude EXCLUDE] [--mini MINI] [--source SOURCE] [--timeout TIMEOUT] [--secure] [--no-pre-allocate] [--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 --no-download Do not perform download test --no-upload Do not perform upload test --single Only use a single connection instead of multiple. This simulates a typical file transfer. --bytes Display values in bytes instead of bits. Does not affect the image generated by --share, nor output from --json or --csv --share Generate and provide a URL to the speedtest.net share results image, not displayed with --csv --simple Suppress verbose output, only show basic information --csv Suppress verbose output, only show basic information in CSV format. Speeds listed in bit/s and not affected by --bytes --csv-delimiter CSV_DELIMITER Single character delimiter to use in CSV output. Default "," --csv-header Print CSV headers --json Suppress verbose output, only show basic information in JSON format. Speeds listed in bit/s and not affected by --bytes --list Display a list of speedtest.net servers sorted by distance --server SERVER Specify a server ID to test against. Can be supplied multiple times --exclude EXCLUDE Exclude a server from selection. Can be supplied multiple times --mini MINI URL of the Speedtest Mini server --source SOURCE Source IP address to bind to --timeout TIMEOUT HTTP timeout in seconds. Default 10 --secure Use HTTPS instead of HTTP when communicating with speedtest.net operated servers --no-pre-allocate Do not pre allocate upload data. Pre allocation is enabled by default to improve upload performance. To support systems with insufficient memory, use this option to avoid a MemoryError --version Show the version number and exit |
示例
1 2 3 4 5 6 7 8 9 10 11 | [root@lhr wondershaper]# speedtest-cli Retrieving speedtest.net configuration... Testing from China Unicom (123.138.73.170)... Retrieving speedtest.net server list... Selecting best server based on ping... Hosted by China Unicom HeNan 5G (Zhengzhou) [434.03 km]: 23.62 ms Testing download speed................................................................................ Download: 99.78 Mbit/s Testing upload speed...................................................................................................... Upload: 23.92 Mbit/s [root@lhr wondershaper]# ll |
Download就是下载速度,Upload就是上传速度,这里的单位是Mbit/s,所以实际我们常用的网速,需要在这个数值基础上除以8.