那么遠程服務器呢?要知道大多數遠程服務器是沒有瀏覽器可以打開web頁面的。用瀏覽器打開網頁測速的瓶頸就在此,你不能按計划的對服務器進行定期的常規測試。這時需要到一個名為Speedtest-cli的軟件來打破這個瓶頸,它能讓你通過命令行來測試互聯網連接的速度。
Speedtest-cli是什么
此程序是基於Python開發的腳本程序,利用了speedtest.net的服務來測量出上下行的寬帶。Speedtest-cli能根據機房離測速服務器的物理距離來列出測速服務器,或者針對某一服務器進行測速,同時還能為你生成一個URL以便你分享你的測速結果。
要在Linux上安裝最新版本的speedtest-cli,你必須安裝2.4-3.4或者更高版本的Python。
在Linux上安裝speedtest-cli
有兩種方法可以安裝speedtest-cli。第一種方法需要用到python-pip包管理器,第二種方法需要安裝Python腳本,生成安裝文件然后運行,這里我們分別介紹兩種方法:
使用pythin-pip安裝speedtest-cli
首先你需要安裝python-pip包管理器,之后你就可以用pip命令來安裝speedtest-cli
$ sudo apt-get install python-pip- $ sudo wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py CentOS
$ sudo pip install speedtest-cli
如果要把speedtest-cli升級至最新版本,你需要輸入以下命令
$ sudo pip install speedtest-cli --upgrade
通過Pyhton腳本來安裝speedtest-cli
首先要用wget命令從github上下來Python腳本,然后解壓提取下載的文件(master.zip)
$ wget https://github.com/sivel/speedtest-cli/archive/master.zip$ unzip master.zip
提取出文件后,進入提取出的目錄speedtest-cli-master然后使腳本可以執行。
$ cd speedtest-cli-master/$ chmod 755 speedtest_cli.py
下一步,把可執行的腳本移動到/usr/bin文件夾,這樣你就不用每次都輸入完整的腳本路徑了。
$ sudo mv speedtest_cli.py /usr/bin/
用speedtest-cli測試互聯網連通速度
1. 要測試你的下載與上傳速度,只需要運行speedtest-cli命令,不需要帶參數。
$ speedtest_cli.py-
$sudo speedtest-cli
Retrieving speedtest.net configuration...
Testing from China Telecom (202.96.128.166)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by ChinaTelecom-GZ (Guangzhou) [2.51 km]: 37.469 ms
Testing download speed................................................................................
Download: 0.65 Mbit/s
Testing upload speed....................................................................................................
Upload: 1.66 Mbit/s
