Vnstat – Network Traffic Monitoring Tool

vnstat is another app that can be used to monitor bandwidth usage. It is a little simpler and easier to use then the ipac-ng package. One of the benefits of vnstat is it’s not a running daemon so it takes up no memory. The process is created via a cron job which is run every 5 minutes.

Install

The vnstat package is very easy to install from the repositories with no dependencies.

sudo apt-get install vnstat

Setup

vnstat is meant to be used by any user so it needs to be set up that way first by giving correct permission. The following gives any user permission to use this feature. If desired you can set up a group so only users in the group can use this.

sudo chmod o+x /usr/bin/vnstat

sudo chmod o+wx /var/lib/vnstat/

Now vnstat should be ready to run

Usage

To create the cron job simply run this command

vnstat -u -i ath0

Replace ath0 with the interface you want to monitor

This creates a file in /var/lib/vnstat/ that collects the data for that interface. A cron job will run every 5 minutes to update the data. Below is a sample output with no options.

Database updated: Thu Jan 12 22:20:01 2006

        ath0

           received:           0.11 MB (nan%)
        transmitted:           0.01 MB (nan%)
              total:           0.12 MB

                        rx     |     tx     |  total
        -----------------------+------------+-----------
            today      0.11 MB |    0.01 MB |    0.12 MB
        -----------------------+------------+-----------
        estimated         0 MB |       0 MB |       0 MB

You can read more about options you can use to modify the output in the man page of vnstat.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s