translated

This commit is contained in:
NearTan 2015-06-12 18:38:21 +08:00
parent ee107f6081
commit 6cc8ebfcfd
2 changed files with 196 additions and 134 deletions

View File

@ -1,134 +0,0 @@
translating by NearTan
How to Test Your Internet Speed Bidirectionally from Command Line Using Speedtest-CLI Tool
================================================================================
We always need to check the speed of the Internet connection at home and office. What we do for this? Go to websites like Speedtest.net and begin test. It loads JavaScript in the web browser and then select best server based upon ping and output the result. It also uses a Flash player to produce graphical results.
What about headless server, where isnt any web based browser and the main point is, most of the servers are headless. The another bottleneck of such web browser based speed testing is that, you cant schedule the speed testing at regular interval. Here comes an application “Speedtest-cli” that removes such bottlenecks and let you test the speed of Internet connection from command line.
#### What is Speedtest-cli ####
The application is basically a script developed in Python programming Language. It measures Internet Bandwidth speed bidirectionally. It used speedtest.net infrastructure to measure the speed. Speedtest-cli is able to list server based upon physical distance, test against specific server, and gives you URL to share the result of your internet speed test.
To install latest speedtest-cli tool in Linux systems, you must have Python 2.4-3.4 or higher version installed on the system.
### Install speedtest-cli in Linux ###
There are two ways to install speedtest-cli tool. The first method involves the use of `python-pip` package while the second method is to download the Python script, make it executable and run, here I will cover both ways….
#### Install speedtest-cli Using pythin-pip ####
First you need to install `python-pip` package, then afterwards you can install the speedtest-cli tool using pip command as shown below.
$ sudo apt-get install python-pip
$ sudo pip install speedtest-cli
To upgrade speedtest-cli, at later stage, use.
$ sudo pip install speedtest-cli --upgrade
#### Install speedtest-cli Using Python Script ####
First download the python script from github using wget command, unpack the downloaded file (master.zip) and extract it..
$ wget https://github.com/sivel/speedtest-cli/archive/master.zip
$ unzip master.zip
After extracting the file, go to the extracted directory `speedtest-cli-master` and make the script file executable.
$ cd speedtest-cli-master/
$ chmod 755 speedtest_cli.py
Next, move the executable to `/usr/bin` folder, so that you dont need to type the full path everytime.
$ sudo mv speedtest_cli.py /usr/bin/
### Testing Internet Connection Speed with speedtest-cli ###
**1. To test Download and Upload speed of your internet connection, run the `speedtest-cli` command without any argument as shown below.**
$ speedtest_cli.py
![Test Download Upload Speed in Linux](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Download-Upload-Speed-in-Linux1.png)
Test Download Upload Speed in Linux
**2. To check the speed result in bytes in place of bits.**
$ speedtest_cli.py --bytes
![Test Internet Speed in Bytes](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Speed-in-Bytes.png)
Test Internet Speed in Bytes
**3. Share your bandwidth speed with your friends or family. You are provided with a link that can be used to download an image.**
![Share Internet Speed Results](http://www.tecmint.com/wp-content/uploads/2015/03/Share-Internet-Speed-Results.png)
Share Internet Speed Results
The following picture is a sample speed test result generated using above command.
![Speed Test Results](http://www.tecmint.com/wp-content/uploads/2015/03/Speed-Test-Results.png)
Speed Test Results
**4. Dont need any additional information other than Ping, Download and upload?**
$ speedtest_cli.py --simple
![Test Ping Download Upload Speed](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Ping-Download-Upload-Speed1.png)
Test Ping Download Upload Speed
**5. List the `speedtest.net` server based upon physical distance. The distance in km is mentioned.**
$ speedtest_cli.py --list
![Check Speedtest.net Servers](http://www.tecmint.com/wp-content/uploads/2015/03/Check-Speedtest-Servers.png)
Check Speedtest.net Servers
**6. The last stage generated a huge list of servers sorted on the basis of distance. How to get desired output? Say I only want to see the speedtest.net server located in Mumbai (India).**
$ speedtest_cli.py --list | grep -i Mumbai
![Check Nearest Server](http://www.tecmint.com/wp-content/uploads/2015/03/Check-Nearest-Server.png)
Check Nearest Server
**7. Test connection speed against a specific server. Use Server Id generated in example 5 and example 6 in above.**
$ speedtest_cli.py --server [server ID]
$ speedtest_cli.py --server [5060] ## Here server ID 5060 is used in the example.
![Test Connection Against Server](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Connection-Against-Server.png)
Test Connection Against Server
**8. To check the version number and help of `speedtest-cli` tool.**
$ speedtest_cli.py --version
![Check SpeedCli Version](http://www.tecmint.com/wp-content/uploads/2015/03/Check-SpeedCLi-Version.png)
Check SpeedCli Version
$ speedtest_cli.py --help
![SpeedCli Help](http://www.tecmint.com/wp-content/uploads/2015/03/SpeedCli-Help.png)
SpeedCli Help
**Note:** Latency reported by tool is not its goal and one should not rely on it. The relative latency values output is responsible for server selected to be tested against. CPU and Memory capacity will influence the result to certain extent.
### Conclusion ###
The tool is must for system administrators and developers. A simple script which runs without any issue. I must say that the application is wonderful, lightweight and do what it promises. I disliked Speedtest.net for the reason it was using flash, but speedtest-cli gave me a reason to love them.
speedtest_cli is a third party application and should not be used to automatically record the bandwidth speed. Speedtest.net is used by millions of users and it is a good idea to [Set Your Own Speedtest Mini Server][1].
Thats all for now, till then stay tuned and connected to Tecmint. Dont forget to give your valuable feedback in the comments below. Like and share us and help us get spread.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/check-internet-speed-from-command-line-in-linux/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/speedtest-mini-server-to-test-bandwidth-speed/

View File

@ -0,0 +1,196 @@
用命令行工具Speedtest-CLI来测试你的上下行网速
================================================================================
我们经常需要到检查家里与办公室之间的网络是否连通那么我们要怎么做呢打开网站Speedtest.net然后开始测试。网站是通过加载浏览器中的JavaScript脚本然后选择最佳的服务器测速然后用Flash产生图形化的结果。
那么远程服务器呢要知道大多数远程服务器是没有浏览器可以打开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 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
<center>
![Test Download Upload Speed in Linux](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Download-Upload-Speed-in-Linux1.png)
在Linux下测试上传下载速度
</center>
**2. 测试上传下载bytes的速度**
$ speedtest_cli.py --bytes
<center>
![Test Internet Speed in Bytes](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Speed-in-Bytes.png)
测试bytes的速度
</center>
**3. 工具提供一个链接来下载由你的宽带测试结果生成的图片,你可以分享给你的家人朋友。**
<center>
![Share Internet Speed Results](http://www.tecmint.com/wp-content/uploads/2015/03/Share-Internet-Speed-Results.png)
分享测速结果
</center>
下面的图片就是你通过以上的命令行测速而生成的图片
<center>
![Speed Test Results](http://www.tecmint.com/wp-content/uploads/2015/03/Speed-Test-Results.png)
测速结果
</center>
**4.如果你仅仅需要Ping上传下载的结果就运行以下命令**
$ speedtest_cli.py --simple
<center>
![Test Ping Download Upload Speed](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Ping-Download-Upload-Speed1.png)
测试Ping上传下载的速度
</center>
**5. 列出`speedtest.net`所有的服务器距离你的物理距离单位是千米km**
$ speedtest_cli.py --list
<center>
![Check Speedtest.net Servers](http://www.tecmint.com/wp-content/uploads/2015/03/Check-Speedtest-Servers.png)
列出Speedtest.net的服务器
</center>
**6. 当获得一个非常长的服务器列表之后怎么列出我想要的某个服务器如果我要在speedtest.net服务器列表中找出位于Mumbai印度的服务器呢**
$ speedtest_cli.py --list | grep -i Mumbai
<center>
![Check Nearest Server](http://www.tecmint.com/wp-content/uploads/2015/03/Check-Nearest-Server.png)
列出最近的服务器
</center>
**7. 对指定的服务器进行测速。我们使用上面例子5和例子6中获取的服务器ID:**
$ speedtest_cli.py --server [server ID]
$ speedtest_cli.py --server [5060] ## Here server ID 5060 is used in the example.
$ speedtest_cli.py --server [5060] ## 这里使用服务器ID为5060作为例子
<center>
![Test Connection Against Server](http://www.tecmint.com/wp-content/uploads/2015/03/Test-Connection-Against-Server.png)
对指定的服务器进行测速
</center>
**8. 输出`speedtest-cli`的版本信息和帮助文档**
$ speedtest_cli.py --version
<center>
![Check SpeedCli Version](http://www.tecmint.com/wp-content/uploads/2015/03/Check-SpeedCLi-Version.png)
输出版本号
</center>
$ speedtest_cli.py --help
<center>
![SpeedCli Help](http://www.tecmint.com/wp-content/uploads/2015/03/SpeedCli-Help.png)
输出帮助文档
</center>
**提醒:**报告中的延迟并不是确切的结果不应该过于依赖它这个数值可以当作相对延迟这对你选择某一测试服务器来说是可靠的。同时CPU和内存的容量会影响结果的准确度。
### 结论 ###
系统管理员和开发者应该必备这个简单的脚本工具这个工具轻量级功能齐全真是太赞了。我不喜欢Speedtest.net的原因是它使用来flash相反speedtest-cli刚好戳中了我的痛点。
speedtest_cli是一个第三方工具也不能自动地记录下宽带速度。Speedtest.net拥有上百万的用户你可以自己[配制一个小型的测速服务器][1]。
上面就是所有内容更多内容敬请关注Tecmint。如果你有任何反馈记得在文章下方评论如果你喜欢别忘了给我们点歌赞分享我们的文章。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/check-internet-speed-from-command-line-in-linux/
作者:[Avishek Kumar][a]
译者:[NearTan](https://github.com/NearTan)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/speedtest-mini-server-to-test-bandwidth-speed/