CentOS下用speedtest-cli进行speedtest测速

Windows 下我们可以很方便的直接浏览器访问 speedtest.net 进行网速测试,在没有图形管理界面的 Linux 系统下,我们也可以用一个小脚本 speedtest-cli 进行测速。

本文使用的小脚本在 CentOS 6、Debian 7、Ubuntu 12.04/14.04 下均测试通过,因为这些发行版都默认包含了 Python 2.7.* 使用起来灰常方便。

一、下载脚本并赋予权限

wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli

curl -o speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli

二、运行方法

默认的测速方法只需要运行一个命令即可:

./speedtest-cli

显示结果如下:

root@example:~# ./speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Earth (192.0.0.2)...
Hosted by Earth (Unknown) [100.00 km]: 100.00 ms
Testing download speed........................................
Download: 100.00 Mbits/s
Testing upload speed..................................................
Upload: 100.00 Mbits/s

但是有时候通过服务器的 IP 判断测速服务器的地理位置并不准确,我们可以通过指定服务器 ID 的方式来进行,首先,打开这个页面:

http://www.speedtest.net/speedtest-servers-static.php

然后可以用 Ctrl + F 搜索您需要的服务器物理位置,比如我想进行香港服务器的测速,找到某个 Hong Kong 节点:

<server url="http://speedtestneta.hkix.net/speedtest/upload.php" lat="22.3000" lon="114.2000" name="Hong Kong" country="China" cc="HK" sponsor="HKIX1" id="5120" url2="http://speedtestnetb.hkix.net/speedtest/upload.php" host="speedtestneta.hkix.net:8080"/>

我们可以看到 ID 是 5120,那么在你的服务器里,只要运行

./speedtest-cli --server 5120

即可指定服务器进行测速

 

我在给我的digitalocean的主机进行测试。国内速度惨不忍睹啊@

[root@jsmio home]# ./speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Selecting best server based on latency...
Hosted by Monkey Brains (San Francisco, CA) [0.10 km]: 12.128 ms
Testing download speed........................................
Download: 899.18 Mbit/s
Testing upload speed..................................................
Upload: 285.15 Mbit/s
[root@jsmio home]# ./speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Selecting best server based on latency...
Hosted by Fastmetrics Inc. (San Francisco, CA) [0.96 km]: 6.036 ms
Testing download speed........................................
Download: 899.63 Mbit/s
Testing upload speed..................................................
Upload: 269.80 Mbit/s
[root@jsmio home]# ./speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Selecting best server based on latency...
Hosted by Fastmetrics Inc. (San Francisco, CA) [0.96 km]: 2.137 ms
Testing download speed........................................
Download: 916.83 Mbit/s
Testing upload speed..................................................
Upload: 285.65 Mbit/s
[root@jsmio home]# ./speedtest-cli --server 4665
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Hosted by China Mobile Group Shanghai Co.,LTD (Shanghai) [9879.57 km]: 478.293 ms
Testing download speed........................................
Download: 8.35 Mbit/s
Testing upload speed..................................................
Upload: 0.84 Mbit/s
[root@jsmio home]# ./speedtest-cli --server5274
Usage: speedtest-cli [options]

speedtest-cli: error: no such option: --server5274
[root@jsmio home]# ./speedtest-cli --server 5274
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Invalid server ID
[root@jsmio home]# ./speedtest-cli --server 3927
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Hosted by China Mobile Jiangsu Co., Ltd. (Suzhou) [9930.90 km]: 1454.785 ms
Testing download speed........................................
Download: 10.85 Mbit/s
Testing upload speed..................................................
Upload: 0.65 Mbit/s
[root@jsmio home]# ./speedtest-cli --server 4751
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Digital Ocean (107.170.251.102)...
Hosted by Beijing Telecom (Beijing) [9503.19 km]: 330.511 ms
Testing download speed........................................
Download: 92.74 Mbit/s
Testing upload speed..................................................
Upload: 14.85 Mbit/s
[root@jsmio home]#

Jason

小角色,喜欢新鲜事物。目前目标:利用互联网来养家糊口!让自己的生活更加精彩。

相关推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注

微信扫一扫,分享到朋友圈

CentOS下用speedtest-cli进行speedtest测速
嘿!有什么能帮到您的吗?
返回顶部

显示

忘记密码?

显示

显示

获取验证码

Close