Run speedtest for linux using the command line utility “speedtest-cli”

What is Speedtest-cli you ask?  The script was developed in python. The script utilizes the speedtest.net infrastructure to perform the speed measurement. 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.  The best way to install and maintain the client is to use “python-pip”.  The “python-pip” requires the python package to be installed and at version 2.4-3.4 or higher.

Below you’ll find several ways to run the utility

Speedtest-cli PIP INSTALL
[root@mwlab01-test ~]# yum install python-pip -q -y
Warning: RPMDB altered outside of yum.
$ sudo apt-get install python-pip
$ sudo pip install speedtest-cli

Speedtest-cli PIP UPGRADE
[root@mwlab01-test ~]# pip install --upgrade pip
You are using pip version 7.1.0, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting pip
Downloading pip-8.0.3-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 147kB/s
Installing collected packages: pip
Found existing installation: pip 7.1.0
Uninstalling pip-7.1.0:
Successfully uninstalled pip-7.1.0
Successfully installed pip-8.0.3

Speedtest-cli INSTALL
[root@mwlab01-test ~]# pip install speedtest-cli
Downloading speedtest_cli-0.3.4-py2.py3-none-any.whl
Installing collected packages: speedtest-cli
Successfully installed speedtest-cli-0.3.4

Speedtest-cli UPGRADE
[root@mwlab01-test ~]# pip install speedtest-cli --upgrade
/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
You are using pip version 7.1.0, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Requirement already up-to-date: speedtest-cli in /usr/lib/python2.7/site-packages

Speedtest-cli HELP
[root@mwlab01-test ~]# speedtest-cli -h
usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list] [--server SERVER] [--mini MINI] [--source SOURCE] [--timeout TIMEOUT] [--secure] [--version] Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------
https://github.com/sivel/speedtest-cli
optional arguments:
-h, --help         show this help message and exit
--bytes            Display values in bytes instead of bits. Does not affect
the image generated by --share
--share            Generate and provide a URL to the speedtest.net share
results image
--simple           Suppress verbose output, only show basic information
--list             Display a list of speedtest.net servers sorted by
distance
--server SERVER    Specify a server ID to test against
--mini MINI        URL of the Speedtest Mini server
--source SOURCE    Source IP address to bind to
--timeout TIMEOUT  HTTP timeout in seconds. Default 10
--secure           Use HTTPS instead of HTTP when communicating with
speedtest.net operated servers
--version          Show the version number and exit

Speedtest-cli VERSION
[root@mwlab01-test ~]# speedtest-cli --version
0.3.4

Speedtest-cli LIST

[root@mwlab01-test ~]# speedtest-cli --list | head -n 20
 Retrieving speedtest.net configuration...
 Retrieving speedtest.net server list...
 5746) MCTV (Massillon, OH, United States) [15.11 km]
 5111) AT&T (Cleveland, OH, United States) [70.47 km]
 5656) Rowe Internet (Byesville, OH, United States) [102.78 km]
 5713) Armstrong (Butler, PA, United States) [125.38 km]
 2132) pair Networks (Pittsburgh, PA, United States) [126.86 km]
 4874) BrescoBroadBand (Columbus, OH, United States) [168.38 km]
 7168) Time Warner Cable (Columbus, OH, United States) [170.93 km]
 3119) RackSquared (Columbus, OH, United States) [170.93 km]
 6962) VNET Fiber (Erie, PA, United States) [175.66 km]
 5359) Suddenlink Communications LLC (Parkersburg, WV, United States) [180.57 km]
 7877) REDNET (Indiana, PA, United States) [190.66 km]
 6039) Citynet (Bridgeport, WV, United States) [201.30 km]
 1298) Amplex (Toledo, OH, United States) [202.50 km]
 6548) MNSi Telecom (Windsor, ON, Canada) [205.38 km]
 1759) Wayne State University (Detroit, MI, United States) [211.89 km]
 5114) AT&T (Detroit, MI, United States) [211.89 km]
 1778) Comcast (Detroit, MI, United States) [211.89 km]
 3673) Shentel Service Company (Weston, WV, United States) [219.80 km]

Speedtest-cli SIMPLE
[root@mwlab01-test ~]# speedtest-cli --simple
Ping: 54.83 ms
Download: 22.45 Mbit/s
Upload: 1.84 Mbit/s

Speedtest-cli SERVER
[root@mwlab01-test ~]# speedtest-cli --server 281
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from AT&T U-verse (75.38.201.237)...
Hosted by ActiveServers (Spokane, WA) [2937.67 km]: 167.484 ms
Testing download speed........................................
Download: 19.11 Mbit/s
Testing upload speed..................................................
Upload: 1.81 Mbit/s

Speedtest-cli SHARE
[root@mwlab01-test ~]# speedtest-cli --server 281 --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from AT&T U-verse (75.38.201.237)...
Hosted by ActiveServers (Spokane, WA) [2937.67 km]: 158.783 ms
Testing download speed........................................
Download: 17.79 Mbit/s
Testing upload speed..................................................
Upload: 1.79 Mbit/s
Share results: http://www.speedtest.net/result/5133742031.png

This has been by far the best tool I’ve used for all of my clients running linux.  Quick results and great that you can perform checks to servers around the world.  Working with systems India/Hungary/Canada/Europe this tool helps to isolate latency between sites.  I hope that you too find it to be helpful.

Download: https://github.com/sivel/speedtest-cli

Leave a Reply

Your email address will not be published.