Internet Speed Monitor

This article will take you through the commanline interface for testing your internet or broadband speed.

Test your internet speed:

Step 0: WiFi Setup

Setup WiFi on your Odinub board by following the step given here.

Step 1: Update your board

Before starting the internet speed monitoring on your Odinub board we must make sure that it is up to date.

For update your Odinub execute following commands.

sudo apt-get update
sudo apt-get upgrade

Step 2: Install require packages

Here we are going to use python for scripting and for internet speed monitoring we are utilizing it’s ‘speedtest-cli’ library. Using this library we can quickle retrive our current upload speed, download speed as well as current ping on Speedtest.net. Before we use this library we must first install python pip package as this library is not available on OS repository. So for this run following command.

sudo apt-get install python-pip

So for installing ’speedtest’ packages go to root directory and execute following command.

Now extract the file you have downloaded.

unzip master.zip

After extracting this file make it executable by going to extracted directory and move this file to usr/local/bin by using following commands.

cd speedtest-cli-master/
chmod 755 speedtest.py
Sudo mv speedtest.py /usr/local/bin/speedtest-cli

Step 3: Test your internet connection speed

Run the following command to test your internet or broadband download and upload speed.

speedtest -cli

If you want to check speed result in bytes than execute following command.

speedtest -cli --bytes

If you want to share the result than you can download the image of the result from the URL provided after executing the following command.

speedtest -cli --share 

 

Image spurce: speedtest.net

If you want the information only about download, upload and ping than run following command.

speedtest -cli --simple 

You can also check the list of server based upon the distance in km by using following command.

speedtest -cli --list

By searching the list in terms of distance you will get a big list of servers. If you want to check the result of servers for a specific area than run the following command.

speedtest -cli --list | grep -i india

 

Step 4: Writing our own speed test python script

Create a python script by executing the following command and write the python code given below.

cd ~
sudo nano speedtest.py

Step 5: Test the python script

Here we are storing our output data in speedtest.csv file so we need to make a folder where it would be store.

mkdir ~/speedtest

Now we will go ahead and test the python script by using following command.

python ~/speedtest.py 

Once the script finished its execution you can see the output by opening the .CSV file by executing the following command.

sudo nano ~/speedtest/speedtest.csv

Step 6: Automating the Internet speed monitor

Now if we want to automation means if we want to test the internet speed of Odinub right after its booting process than click here and follow the first two steps.

You just have to write the below line into rc.local file.

(sleep 30; python ~/speedtest.py)&

You can see the results when you reboot you Odinub.

So that's it. Now you guys should have your speed monitor uo and running. I hope by end of this article you should now have your Odinub automatically internet speed monitor. If you do come across something then please feel free to send us your feedback.

 

Code :
Code Title :
speed.py
Code Language :
Python
0 Commenting Overall Comment