(: August 16, 2019)
The proliferation of internet connectivity has come with numerous opportunities that were only far dreams more than two decades ago. As more people get into the web, speed of access to web resources whether videos, web content or e-books has become something of such importance that no one can afford to ignore.
People all over the globe loathe slow speeds especially when they are following their favorite TV series or downloading their favorite content online. Due to this, thanks to the opensource community, tools have been developed to check the kind of speeds that exist between your computer and the resources you are eager to consume.
One of the tools that you will easily find out there is speedtest. We are sure you have heard of the speedtest website where you get to measure the speed of your internet connectivity. It is a wonderful tool until you are in a server without GUI or a browser and you still need to check your speed connectivity. This guide fills that gap because it shows how to install and use speedtest-cli. As the name suggests, it is a command-line version of speedtest and you can easily install and use it in your minimal/core Linux server.
This guide shows how to install speedtest-cli using Ansible on Ubuntu 18.04 and CentOS 7 and how you can use it to test your connectivity speeds.
We assume you have installed Ansible environment, python and python-setuptools (for Ubuntu) and are all working well. The installation script depends on python-setuptools for Ubuntu.
Step one: Edit your inventory file
You can use your default /etc/ansible/hosts file or you can create a new one as well as long as you specify it while running your playbook
$ sudo vim /etc/ansible/hosts # Add your server IPs [worker1] 172.21.98.186
Step Two: Create your Playbook as shown below
--- - hosts: worker1 become: true tasks: - name: Check if Python is installed raw: test -e /usr/bin/python changed_when: false failed_when: false register: check_python - name: Install Python and setuptools raw: test -e /usr/bin/apt && (apt -y update && apt install -y python-setuptools && apt install -y python) || (yum -y install python libselinux-python) when: check_python.rc != 0 - name: Auto-Create project directory to dump speedtest-cli files from git file: path=/tmp/test state=directory - name: Get speedtest-cli from git git: repo=https://github.com/sivel/speedtest-cli.git dest=/tmp/test/ - name: Change to speedtest-cli directory and install it become: yes command: chdir=/tmp/test/ python setup.py install
Once the Playbook has run successfully, it is time to use speedtest-cli. Let us get on it.
The simplest speedtest using speedtest-cli is by simply running it on your terminal as:
$ speedtest-cli Retrieving speedtest.net configuration…
The above will measure upload and download speeds in reference to the closest server that it will find.
In case you would wish to measure your speed against a server of your choice, then you must know its id. To get the id of the server, please run the following
$ speedtest-cli --list
This will generate a very long list of servers. However, you can, of course, grep the results using your City name for example:
$ speedtest-cli --list | grep New York 13098) Pilot (New York, NY, United States) [11842.04 km] 16976) Spectrum (New York, NY, United States) [11842.04 km] 5029) AT&T (New York, NY, United States) [11842.04 km] 10390) Speedtest.net (New York, NY, United States) [11842.04 km] 663) Optimum Online (New York, NY, United States) [11842.04 km] 18381) AT&T Wireless (New York, NY, United States) [11842.04 km] 16888) Natural Wireless (New York, NY, US) [11842.04 km] 7170) ISPnet, Inc (New York, NY, United States) [11842.04 km] 10546) Sprint (New York, NY, United States) [11842.04 km] 16686) CCleaner (New York, NY, United States) [11842.04 km] 21016) Starry, Inc. (New York, NY, United States) [11842.04 km] 21313) Data Room (New York, NY, United States) [11842.04 km] 6030) fdcservers.net (New York, NY, United States) [11842.04 km] 18956) Hivelocity Hosting (New York, NY, United States) [11842.04 km] 20326) Honest.net (New York, NY, United States) [11842.04 km] 24374) GTT.net (New York, NY, United States) [11842.04 km] 22715) Newforce Solutions (New York, NY, United States) [11842.04 km] 25070) Stealth Communications (New York, NY, United States) [11842.04 km] 26314) Castcrown Limited (New York, NY, United States) [11842.04 km] 18098) Atlantic Metro (New York, NY, United States) [11842.04 km] 25168) MinhaLista (New York, NY, United States) [11842.04 km]
After you have the list, you can now choose the one you would like to use then run
$ speedtest-cli --server 13098 # for Pilot (New York, NY, United States) server. Retrieving speedtest.net configuration…
If you would prefer to use bytes per second instead of bits per second by default, just use the –bytes option and you are good to go.
$ speedtest-cli --bytes --server 6030 Retrieving speedtest.net configuration…
There are a few more options that you may find interesting for your use. More information can be found at:
Now you have a working speedtest-cli and we hope it will help you in your use-case. Thank you for visiting and reading through. Check below for other guides you might be interested in: