CentOS下用speedtest-cli 進行測速

來源:互聯網
上載者:User

CentOS下用speedtest-cli 進行測速

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.pychmod +x speedtest-cli

或

curl -o speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.pychmod +x speedtest-cli
二、運行方法

預設的測速方法只需要運行一個命令即可:

./speedtest-cli

顯示結果如下:

root@example:~# ./speedtest-cliRetrieving speedtest.net configuration...Retrieving speedtest.net server list...Testing from Earth (192.0.0.2)...Hosted by Earth (Unknown) [100.00 km]: 100.00 msTesting download speed........................................Download: 100.00 Mbits/sTesting 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

即可指定伺服器進行測速

有時候可能你的伺服器訪問http://www.speedtest.net/speedtest-servers-static.php會 403 Forbdden 錯誤,這是因為你伺服器的網路被 speedtest.net 給屏蔽了,自己簡單的做個Nginx 反代然後修改speedtest-cli檔案即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.