Reputation: 1431
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.
Upvotes: 3
Views: 5485
Reputation: 1146
vnstat --version
vnStat 2.6 by Teemu Toivola <tst at iki dot fi>
sudo vnstat --add -i usb0
Adding interface "usb0" for monitoring to database...
Restart the vnStat daemon if it is currently running in order to start monitoring "usb0".
sudo systemctl restart vnstat
systemctl status vnstat
● vnstat.service - vnStat network traffic monitor
Loaded: loaded (/lib/systemd/system/vnstat.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-08-28 23:51:15; 3s ago
Docs: man:vnstatd(8)
man:vnstat(1)
man:vnstat.conf(5)
Main PID: 253536 (vnstatd)
Tasks: 1 (limit: 8971)
Memory: 736.0K
CGroup: /system.slice/vnstat.service
└─253536 /usr/sbin/vnstatd -n
timestamp comp systemd[1]: Started vnStat network traffic monitor.
timestamp comp vnstatd[253536]: Info: vnStat daemon 2.6 started. (pid:253536 uid:131 gid:139 64-bit)
timestamp comp vnstatd[253536]: Info: Monitoring (1): usb0 (1000 Mbit)
Tested on Ubuntu 20.04.
Upvotes: 0
Reputation: 31
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.
Upvotes: 2
Reputation: 569
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.
Upvotes: 4
Reputation: 106
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
.
Upvotes: 9