Linux vnstat not getting updated

 

vnStat is a console-based network traffic monitor tool.

To install vnstat run any of following command depending on you operating system.

$ yum install vnstat (CentOS/Fedora)

$ apt-get install vnstat (Ubuntu/Debian)

Next the used kernel should be checked that it is able to provide static information about the system boot time.

$ vnstat --testkernel

The only way to fix a faulty kernel (afaik) is to download compile/install a newer version of vnstat.

Next every interface that should be monitored needs to be introduced to vnStat. Replace ‘eth0’ in the command with any available interface if needed.

$ vnstat -u -i eth0

Repeat that for every other interface you wish to use. If you are unsure of available interface names then run

$ vnstat --iflist

After installing it may not update the vnstat database directly.

Check if vnstat daemon is running or not with following command:

$ ps aux | grep vnstatd

Output:

root 27576 0.0 0.0 1952 576 ? Ss 09:43 0:00 vnstatd -d

If you couldn’t see above output, it means update daemon is not running.

To start update daemon run following command:

$ vnstatd -d

Now again check with following command:

$ ps aux | grep vnstatd

You should get following output:

root 27576 0.0 0.0 1952 576 ? Ss 09:43 0:00 vnstatd -d

To get network usage statistics run following command:

$ vnstat -d (To get daily stats)

$ vnstat -h (To get hourly stats)

$ vnstat -m (To get monthly stats)

Even though after doing all the above configurations statistics may not get updated. To resolve this download the /etc/init.d script from the link.

Since I testing on Centos downloaded the script from url http://humdi.net/vnstat/init.d/redhat/vnstat

After downloading script give the executable permissions for the script with following command:

$ chmod a+x vnstat

Then copy the script to /etc/init.d/

To start vnstatd use following command:

$ service vnstat start

To stop vnstatd use following command:

$ service vnstat stop

To restart vnstatd use following command:

$ service vnstat restart

To start vnstatd on boot use following command:

$ chkconfig vnstat on

-Sany