Traffic Monitor: 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.

Installation

It’s easy to install vnStat, just run the following command in your console (for CentOS), and that’s all you need to do.

yum -y install vnstat

Create vnStat database

Before create vnStat database, make sure which network interface you want to monitor, take eth0 for example.

vnstat -u -i eth0

It’s done, and vnStat is gathering traffic information for you, both received and transfered.

Command Manual

vnstat -h Show traffic statistics on a hourly basis for the last 24 hours.

vnstat -d Show traffic statistics on a daily basis for the last 30 days.

vnstat -m Show traffic statistics on a monthly basis for the last 12 months.

vnstat -l Display current transfer rate for the selected interface in real time until interrupted.

Statistics will be shown after interruption if the runtime was more than 10 seconds.

The commands above are commonly used, for detailed manual please take a look at official manual page.

Troubleshooting

If you were encountered a problem of “eth0: Not enough data available yet.”, please make sure vnStat is running. Here is the command of check the status:

/etc/init.d/vnstat status

If it wasn’t running, run the follwoing command and you will able to get traffic information in 5 minutes.

/etc/init.d/vnstat start

Leave a Reply

Your email address will not be published. Required fields are marked *