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

odol (not verified)
December 20th, 2009 09:16 pm
Nice..!!!!!!
Hypercom Manuals (not verified)
April 5th, 2010 09:02 am
I use my DDRT54 router as it catches the entire houses traffic, but this is good too :)
Wage Garnishment (not verified)
August 20th, 2010 08:04 pm
Thank you for posting this article. I will bookmark your site to read more of your updated post.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.