vnstat not updating

Run

sudo chown -R vnstat:vnstat /var/lib/vnstat

This fixed my problem on Ubuntu 14.04.

Make sure you have following files in that folder and have proper ownership.

boby@fwhlin:/var/lib/vnstat$ ls -la
total 16
drwxr-xrwx  2 vnstat vnstat 4096 May 16 01:50 .
drwxr-xr-x 78 root   root   4096 Jul 22 15:14 ..
-rw-r--rwx  1 vnstat vnstat 2792 Jul 26 00:26 eth0
-rw-rw-r--  1 vnstat vnstat 2792 Jul 26 00:26 .eth0
boby@fwhlin:/var/lib/vnstat$ 

.eth0 is temp file, that may disappear sometimes.


After installing vnstat the database need to be created (one time). To create the database you can use the update switch, which create new database in the base of no database. Create DB: sudo vnstat -i eth0 -u where eth0 is the name of the network interface. If you are unsure update for all interfaces by sudo vnstat -u. After sometime (1 minute) you can view the details vnstat -i eth0 or simply vnstat .

Update

It seems vnstat not running ! . Start the daemon by running sudo /etc/init.d/vnstat start and check for the result after 5 minutes.

Example

sudo vnstat -u -i eth0

Error: Unable to read database “/var/lib/vnstat/eth0. Info: -> A new database has been created.

sudo /etc/init.d/vnstat start
  • Starting vnStat daemon vnstatd [ OK ]

Once database have been initialiase, its ready to monitor bandwidth usage. You can view the report by invoke command vnstat.


Same issues here.

After checking the details it turned out that the databases for the different devices (eth0, ppp0, wlan0, etc.) were created in /var/lib/vnstat but these files were owned by the USER. After sudo chown -R vnstat:vnstat /var/lib/vnstat it seems to be ok. I also had to check the default interface in /etc/vnstat.conf - it was the wrong one for me, so I just changed it.