Monitor your Internet Traffic Stats using Vnstat
A few days ago, I got the last month's Internet Bill. And due to overusage I had to pay 4 times the usual. That's when I realized that I definitely need to keep a check on my Internet usage. Vnstat is a simple console based tool built for such purposes. It keeps a log of the network traffic for the selected interface(s). It can show the usage stats in various formats (daily, monthly even live mode is available). It has proved to be a real life(actually money
) saver for me.
The best thing about Vnstat is that it doesn't sniff any traffic so its light on the resources. It collects all the data from the /proc directory so you don't have to be a root user to run it. It is pretty easy to install and use.
Installation
For Ubuntu users:
[shredder12]$ sudo apt-get install vnstat
For Fedora users:
[root]# yum install vnstat
Others may download the zipped package from their website.
Configuration
Once it is installed you might want to change the permissions so that every user on the machine can use it. Run the following commands to allow it to every user.
[root]# chmod o+wx /var/lib/vnstat/
[root]# chmod o+x /usr/bin/vnstat
Now, run the following command to select an interface eth0 for monitoring
[shredder12]$ vnstat -u -i eth0
The data for each interface is saved in a database of the same name in /var/lib/vnstat/. Using the above command you can update that database. A new database will be created if one doesn't exist. You can create databases for other interfaces similarly and can view the traffic data using this command
[shredder12]$ vnstat -i <interface>
You can even view the live stats by using the --live attribute.
[shredder12]$ vnstat --live -i <interface>
There are a lot of other options mentioned in its manpage and I am sure you linuxers won't have any problem using them :).






































3 Comments
Post new comment