Linux vnstat - A Console Network Traffic Monitoring Tool

There are a lot of network monitoring tool in the internet. The most popular one may be Multi Router Traffic Graph or known as MRTG. To access MRTG, we need to install a web server. If you don’t want to install a web server, you may want to use vnstat as an MRTG alternative. Vnstat is run in console mode.

Let’s start to know more about vnstat.

What is vnstat?

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. However, in Linux at least a 2.2 series kernel is required. -- Reference : vnstat website


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, the we need to compile it first.

On Redhat / 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

Running vnstat at the first time

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 detail with 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 clear information about megabtyes that you have send / receive in many format such as hours, days, week and month.

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


Share This :

Free Linux Ebook to Download

Comments (2)

Trackback URL | Comments RSS Feed

  1. vnstat uses a daemon : vnstatd

    $ vnstat -v
    vnStat 1.10 by Teemu Toivola

    $ ps aux |grep vnstat
    root 1724 0.0 0.0 6524 628 ? Ss 09:12 0:00 /usr/sbin/vnstatd -d

    • Bobbin Zachariah says:

      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 Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.