UNPKG

3.67 kBMarkdownView Raw
1speedtest-cli
2===
3
4命令行下测试服务器外网速度
5
6## 补充说明
7
8**speedtest-cli** 是一个使用python编写的命令行脚本,通过调用speedtest.net测试上下行的接口来完成速度测试,最后我会测试运维生存时间所在服务器的外网速度。项目地址:https://github.com/sivel/speedtest-cli
9
10### 安装speedtest-cli
11
12speedtest-cli需要在python 2.4-3.4的环境下,安装方法都很简单,自己选择以下最适合你的一种。
13
14 **pip方式**
15
16```shell
17# pip install speedtest-cli
18```
19
20 **easy_install方式**
21
22```shell
23# easy_install speedtest-cli
24```
25
26 **github+pip方式**
27
28```shell
29# pip install git+https://github.com/sivel/speedtest-cli.git
30```
31
32或者
33
34```shell
35# git clone https://github.com/sivel/speedtest-cli.git
36# python speedtest-cli/setup.py install
37```
38
39 **下载脚本方式**
40
41```shell
42# wget -O speedtest-cli https://raw.github.com/sivel/spe ... er/speedtest_cli.py
43# chmod +x speedtest-cli
44```
45
46或者
47
48```shell
49# curl -o speedtest-cli https://raw.github.com/sivel/spe ... er/speedtest_cli.py
50# chmod +x speedtest-cli
51```
52
53直接下载脚本,给予执行权限即可。
54
55### 用法
56
57```shell
58-h, --help show this help message and exit
59--share 分享你的网速,该命令会在speedtest网站上生成网速测试结果的图片。
60--simple Suppress verbose output, only show basic information
61--list 根据距离显示speedtest.net的测试服务器列表。
62--server=SERVER 指定列表中id的服务器来做测试。
63--mini=MINI URL of the Speedtest Mini server
64--source=SOURCE Source ip address to bind to
65--version Show the version number and exit
66```
67
68### 实例
69
70列出所有在中国的测试服务器:
71
72```shell
73[root@li229-122 ~]# speedtest-cli --list | grep China
741185) China Unicom (Changchun, China) [10534.35 km]
753784) China Mobile (Urumqi, China) [10581.15 km]
762667) Beijing Normal University (Beijing, China) [11117.03 km]
772529) Beijing Normal University (Beijing, China) [11117.03 km]
782816) Capital Online Data service (Beijing, China) [11117.03 km]
794354) SXmobile (Taiyuan, China) [11383.17 km]
803973) China Telecom (Lanzhou, China) [11615.43 km]
813633) China Telecom (Shanghai, China) [11983.37 km]
823927) China Mobile Jiangsu Co., Ltd. (Suzhou, China) [11989.27 km]
832461) China Unicom (Chengdu, China) [12213.35 km]
841028) Shepherd Software (Xiamen, China) [12785.57 km]
851628) Xiamen Guangdian Xinxu (Xiamen, China) [12785.57 km]
863891) GZinternet (Guangzhou, China) [13005.36 km]
873871) SZWCDMA (Shenzhen, China) [13059.20 km]
883819) SZU (Shenzhen, China) [13059.20 km]
891536) STC (Hong Kong, China) [13088.37 km]
901890) Telin (Hong Kong, China) [13088.37 km]
91```
92
93 **结果解释**
94
95```shell
963633) China Telecom (Shanghai, China) [11983.37 km]
97```
98
99```shell
1003633: 服务器id
101china telecom:isp,这里是中国电信
102shanghai,china :服务器所在地址
10311983.37 km:两台服务器地理位置之间距离,我这台机器在美国,和上海相距11983.37公里,很远呐.
104```
105
106 **外网速度测试**
107
108```shell
109[root@li229-122 ~]# speedtest-cli --server=3633 --share
110Retrieving speedtest.net configuration...
111Retrieving speedtest.net server list...
112Testing from Linode (173.255.219.122)...
113Hosted by China Telecom (Shanghai) [11983.37 km]: 23.603 ms
114Testing download speed........................................
115Download: 24.84 Mbit/s
116Testing upload speed..................................................
117Upload: 4.57 Mbit/s
118Share results: http://www.speedtest.net/result/3240988007.png
119```
120
121
122<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
\No newline at end of file