Linux命令列測試網速
很多時候我們需要測試Linux伺服器的上行和下行寬頻。在可用於測試寬頻速度的網站中,Speedtest.net也許是使用最廣泛的應用“之一”。
Speedtest.net提供了一個命令列版本——speedtest-cli。下面將向你示範如何在Linux的命令列中使用speedtest-cli來測試寬頻連線速度。
一、安裝speedtest-cli
speedtest-cli是一個用Python編寫的輕量級Linux命令列工具,在Python2.4至3.4版本下均可運行。它基於Speedtest.net的基礎架構來測量網路的上/下行速率。安裝speedtest-cli很簡單——只需要下載其Python指令檔。網上的教程非常古老,用了只會報到期指令碼 ,更新如下
wgethttps://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod a+rx speedtest.py
mv speedtest.py /usr/local/bin/speedtest-cli
chown root:root /usr/local/bin/speedtest-cli
speedtest-cli
也可以在自己電腦上下載好 speedtest.py 然後上傳到伺服器上。
二、使用speedtest-cli測試網速
使用speedtest-cli命令也很簡單,它不需要任何參數即可工作。
[root@localhost temp]# speedtest-cli
輸入這個命令後,它會自動探索離你最近的Speedtest.net伺服器(地理距離),然後列印出測試的網路上/下行速率。
[root@localhost temp]# speedtest-cli
Retrieving speedtest.net configuration…
Retrieving speedtest.net server list…
Testing from China Telecom (219.135.214.145)…
Selecting best server based on latency…
Hosted by CTM Internet Services (Macau) [106.48 km]: 55.974 ms
Testing download speed………………………………….
Download: 3.15 Mbit/s
Testing upload speed…………………………………………..
Upload: 0.58 Mbit/s
測試結果說明:上行為 0.58Mbit/s 下行為 3.15 Mbit/s
當然對於測試結果,一般在實際應用中不一定能達到這個值,僅作為參考使用。