- Advertisement -
Rumble Ad

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.
In this article we will show you how to install and use vnStat (Network Traffic Monitor) on RHEL/CentOS linux distribution.

vnstat features

    • quick and simple to install and get running
    • gathered statistics persists through system reboots
    • can monitor multiple interfaces at the same time
    • several output options
      • summary, hourly, daily, monthly, weekly, top 10 days
      • optional png image output (using libgd)
  • months can be configured to follow billing period
  • light, minimal resource usage
  • same low cpu usage regardless of traffic
  • can be used without root permissions

Install VnStat on RHEL/CentOS 6.x/7.x Linux

To start, you will need to enable the EPEL repositories for your version of Linux. To enable the EPEL repositories in CentOS/RHEL 6.x enter following command:

[php]$wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
$rpm -ivh epel-release-latest-6.noarch[/php]

To enable the EPEL repositories in CentOS/RHEL 7.x enter following command:

[php]$ yum -y install epel-release[/php]

Next, you can install VnStat as normal through yum.

- Advertisement -
pCloud Ad

[php]$ yum -y install vnstat[/php]

Once installed, the default configuration will work for most people. The default will run on the eth0 interface. If you need to change the interfaces, you will need to edit two files. It’s self explanatory. Change the occurrences of eth0 to eth1 (or your choice of interface).

[php]nano /etc/sysconfig/vnstat
nano /etc/vnstat.conf[/php]

Next, we need to create the database where the data will be collected and stored. The command may generate an error. If it does, that’s fine. It is because the new file is created with ownership of the logged in user. We will fix this by running a chown on the file before starting the service.

[php]$ vnstat -u -i eth0
$ chown vnstat:vnstat /var/lib/vnstat/eth0[/php]

That’s it. You’re ready to start the service and start collecting data.

[php]$ service vnstat start
$ chkconfig vnstat on[/php]

How to use VnStat

Using VnStat command line utility you can view statistics on bandwidth on per day, per month and per hour basis. It also provides option to show statistics in real-time.

Show Statistics for a day

To see daily stats, enter:

[php]$ vnstat -d[/php]


Show Statistics for a Month

To see monthly network stats, enter:

[php]$ vnstat -m[/php]


Show Statistics for a weekly

To see weekly network stats, enter:

[php]$ vnstat -w[/php]


Show Statistics for a Hour

To see hourly network stats, enter:

[php]$ vnstat -h[/php]


Show top 10 network stats

To see top 10 network, stats:

[php]$ vnstat -t[/php]


Show Statistics in Real Time

To see transfer rate in real time, enter:

[php]$ vnstat -l[/php]

That is all. Lots more information about the usage and options can be found out in the vnStat man page.

- Advertisement -