If you are one of those unlucky few who has a data cap like I do on my BSNL connection then you will definitely need something reliable to monitor the amount of data transferred. BSNL’s site seem to work for people who have one of the earlier 59.x.x.x IP addresses but for new users they seem to be giving out bsnl.in accounts and the site you use to log the usage for these accounts is horrific. It doesn’t take into account the amount of data you are allowed to download. That is right now at my first month it says I already owe them Rs. 270 for downloading 304,000 + KB . In other words for 296 MB I’ve been charged Rs. 270. However the plan guarantees that you are allowed 1GB of data transfer.
Anyway Ive been logging my usage correctly with the tool called vnstat. vnstat is a command line tool which will log any usage on the interface you define. In my case its my ethernet card whichconnectes to my ADSL router. The one disadvantage of this method is that it uses a command line interface and might intimidate some. None the less there is a front end available which you can use to access the statistics through a web browser.
To install vnstat first enter the following command in your terminal.
sudo apt-get install vnstat
After that you need to create the database vnstat needs to log the data it stores and also specify the interface you can you would like to use. If you are connecting through a network card then usually its going to be eth0. If you would like to monitor your dial up traffic the interface would be ppp0 in normal cases as well. None the less you can find out which interface you are using by using the following command in a terminal.
ifconfig
Once you know which interface you are using you would enter the following command.
vnstat -u -i interface
Here interface refers to the interface you are using for your internet connection. In my case I used eth0.
Now you can view the data in your terminal by using one of these commands
vnstat -d
vnstat -m
vnstat -w
Here d refers to the output in days , w in weeks and -m in months.

You can see more information about the command vnstat by using the command .
man vnstat
Now that you have the backend for monitoring the throughput installed it’s time to install the front end as well. For this first you need to download its front end which you can get from here. After downloading that lets check what all we need for the above to work.
- We are going to need to install a web server for this to work. Although I’m using Apache2 there are other alternatives you can try like thttpd. Anyway for this example we will be using Apache2.
- Next we are going to have to install the PHP mod for Apache to get the PHP files in the front end to work properly.
- Finally we will need the image mod for Apache which will allow to display images within the pages.
Now lets install Apache2 and the other needed components by using the following commands.
sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5
sudo apt-get install php5-gd
Now that you have all the needed stuff required for viewing vnstat through your browser lets configure the rest to work. Go to the folder you have the vnstat frotn end downloaded. Then enter this:
sudo tar zxvf vnstat_php_frontend-x.x.x.tar.gz --directory=/var/www/
You want to substitute the x.x.x with the proper numbers of the file you downloaded. This will extract all the contents to the /var/www folder which Apache uses to display its web pages. Now open the file config.php using the following command.
sudo gedit /var/www/config.php
Edit the interfaces in there by changing it to the interface you used in the vnstat command above. Save the file and exit. Now Open the browser you are using and try http://localhost. If everything turned out alright then you should get the a similar picture as shown below.
You can read more about vnstat and the installation process at these sites.
Vnstat Front End Home Page
Vnstat Home Page









