Linux vnstat - A Console Network Traffic Monitoring Tool

VnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s). It uses the network interface statistics provided by the kernel as information source. This means that vnStat won't actually be sniffing any traffic and also ensures light use of system resources.

Install Vnstat

Vnstat is available in source code file. The latest version is version 1.11 which can be download it from its download page. Since vnstat is available only in source code form, need to compile it first.

On Redhat  and CentOS based you can do this steps:

Extract the file

$ tar zxfv vnstat-1.11.tar.gz

Compiling vnstat

$ cd vnstat-1.11
$ ./configure
$ make

Installing vnstat

You may need root privileges for it

$ su
Password :

# make install

Run vnstat

By default vnstat is installed in /usr folder. Then you will found vnstat binary file in /usr/bin/vnstat

For first time, you will need to create a database for it. To make a new database, use the command below. You may need a root privilege to run the command.

# /usr/bin/vnstat

First running

Vnstat still not find any database for it. But as you see at the screenshot, vnstat tell you how many interfaces that available. To double-check what interface that you want to monitor, run :

$ ifconfig

Network Interface Info

From the screenshot above we found eth1 is active. To monitor it, run this command :

$ /usr/bin/vnstat -u -i eth1

First time running

Don’t worry about the error above. It is normal for the first time. To check it does it running well or not, run this command :

$ /usr/bin/vnstat -l -i eth1

Here’s the sample output :

Vnstat display

More options of vnstat

Here’s some parameter that could be useful in daily operation.

Show hours based traffic

$ /usr/bin/vnstat --hours

View vnstat hourly

Show days based traffic

$ /usr/bin/vnstat --days

View vnstats daily

Show weeks based traffic

$ /usr/bin/vnstat --weeks

View vnstat weekly

Show months based traffic

$ /usr/bin/vnstat --months

View vnstat monthly

Show Top 10 traffic

$ /usr/bin/vnstat --top10

View vnstat Top 10

Calculate traffic

$ /usr/bin/vnstat -tr

Calculate traffic

Show transfer rate in real time

$ /usr/bin/vnstat -l

View vnstat real-time


I found it useful for daily operation. The advantage of vnstat there is no daemon service is running in the backgroud. Vnstat use cronjob to run periodically that make makes vnstat very light. You can also control everything via console mode. Vnstat also give you a piece of clear information about megabtyes that you have send/receive in many formats such as hours, days, week and month.

Please visit vnstat website to look more details or type man vnstat on your console.

2 Comments... add one

    • Hi Stéphane ,
      Thanks for the comments.
      Right !! daemon could be used for more flexible way for updating database.
      Could also use cron job to update the same. Cron based update might need additional script.
      Running vnstatd would be more handy


Leave a Comment