天天看點

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腳本檔案。

[root@localhost temp]# wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py [root@localhost temp]# chmod a+rx speedtest_cli.py [root@localhost temp]# mv speedtest_cli.py /usr/local/bin/speedtest-cli [root@localhost temp]# chown root:root /usr/local/bin/speedtest-cli

也可以在自己電腦上下載下傳好 speedtest_cli.py 然後上傳到伺服器上。

二、使用speedtest-cli測試網速

使用speedtest-cli指令也很簡單,它不需要任何參數即可工作。

[root@localhost temp]# speedtest-cli

輸入這個指令後,它會自動發現離你最近的speedtest.net伺服器(地理距離),然後列印出測試的網絡上/下行速率。

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

當然對于測試結果,一般在實際應用中不一定能達到這個值,僅作為參考使用。