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.
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
$ cd vnstat-1.11 $ ./configure $ make
You may need root privileges for it
$ su Password : # make install
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.
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 :
From the screenshot above we found eth1 is active. To monitor it, run this command :
$ /usr/bin/vnstat -u -i eth1
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 :
More options of vnstat
Here’s some parameter that could be useful in daily operation.
Show hours based traffic
$ /usr/bin/vnstat --hours
Show days based traffic
$ /usr/bin/vnstat --days
Show weeks based traffic
$ /usr/bin/vnstat --weeks
Show months based traffic
$ /usr/bin/vnstat --months
Show Top 10 traffic
$ /usr/bin/vnstat --top10
$ /usr/bin/vnstat -tr
Show transfer rate in real time
$ /usr/bin/vnstat -l
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.