Question

vnstat is updating only one interface every five minutes. I have to use vnstat -u to manually update the rest of interfaces. All interfaces are already enabled, but only one interface is updating every 5 minutes.

Was it helpful?

Solution

Check which user the vnstat daemon is running as using ps aux | grep [v]nstat.

I recently had the same problem and after priming the database with vnstat -u -i eth0 as root the vnstat process couldn't write to the /var/lib/vnstat/eth0 file as it was running as user "vnstat".

If vnstat is running as user "vnstat" ensure that it has permission to write to /var/lib/vnstat/eth0.

OTHER TIPS

When you add the interface for eth0 or ppp0 or whatever, make sure you do it as the vnstat user. ie

sudo -u vnstat vnstat -i ppp0 -u

If you run this as root first you are will have problems even if you chmod the file in /var/lib/vnstat. This is due to the creation of a back file called .ppp0 which you might miss if you are not looking for it. There will be an error in syslog saying that the backup file cannot be written.

So I was having a similar problem where i was getting the following:

$ vnstat -i eno1

eno1: not enough data available yet

I also tried every other command while pointing to eno1. I would sometimes even get:

Error: Unable to create database backup "/var/lib/vnstat/.eno1" OR Segmentation fault (core dumped)

I tried reinstalling, and everything else under the sun.

Following Andrew's answer to the 't' returned:

Error: Unable to open database "/var/lib/vnstat/eno1" for writing: Permission denied

so instead I did the following, but I'm not sure which one of these commands did the trick.

$ sudo vnstat -i eno1 -u $ sudo vnstat -u -i eno1

Then I checked to see if the interface was working again:

$ sudo vnstat -i eno1

which returned:

> Database updated: Wed Dec 5 10:17:37 2018

(eno1) since 1969-12-31

      rx:  2 KiB      tx:  1 KiB      total:  3 KiB

monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- Dec '69 2 KiB | 1 KiB | 3 KiB | 0.00 kbit/s ------------------------+-------------+-------------+--------------- estimated -- | -- | -- |

daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- today 2 KiB | 1 KiB | 3 KiB | 0.00 kbit/s ------------------------+-------------+-------------+--------------- estimated -- | -- | -- |

Now its finally able to read and write to eno1 log. I noticed this problem since conky was not showing up any stats reports on today && Month && total. I wasn't expecting anything under month, but after a couple days I was expecting something under hours.

I realise the rest will take a while to populate with data. But now I know for sure it is working. Also, my conky app is finally displaying the information.

However, prior to this solution, I had already chmod the file.

Additional info for newbies such as myself: - make sure to check which interface you are using, I often see solutions for eth0 and others that do not appear when using "$ ifconfig". Enter:

$ ifconfig

and you should see on the left hand side of the results the interface name. Mine are, eno1, lo, and wlo1.

next to the label: "Link encap:" it should say if it is wireless, ethernet, or local loopback

lo is the local loopback a.k.a localhost/127.0.0.1

What I am not sure of, in my case, is the difference between eno1 and wlo1. they both say "Ethernet". I wonder if doesn't have something to do with my direct wifi printer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top