Error: Unable to read database "/var/lib/vnstat/eth0": No such file or directory
This error will appear when vnstat is not configured to the correct netwrork interface. You can check what interface your device is using with ifconfig:
$ ifconfig
enp3s0: flags=4163 mtu 1500
...
And to make sure your vnstat is monitoring your identified network interface you can check for the database files located in: /var/lib/vnstat/
$ ls /var/lib/vnstat
enp3s0 wlp2s0
Now you just need to add it to your vnstat config. You could simply edit the default config file located at /etc/vnstat.conf
which would apply globally. However it is recommended to create a local config for your user. Copy the global config into your home directory like so:
$ cp /etc/vnstat.conf ~/.vnstatrc
And update the default database to your selected network interface:
# default interface
Interface "enp3s0"
Save and you should be able to run vnstat and check your bandwidth stats.
$ vnstat -d
enp3s0 / daily
day rx | tx | total | avg. rate
------------------------+-------------+-------------+---------------
07/08/2019 61.04 MiB | 6.05 MiB | 67.09 MiB | 6.51 kbit/s
07/09/2019 25.36 MiB | 152.33 MiB | 177.69 MiB | 17.25 kbit/s
07/10/2019 10.38 MiB | 2.12 MiB | 12.51 MiB | 2.38 kbit/s
------------------------+-------------+-------------+---------------
estimated 19 MiB | 3 MiB | 22 MiB |
Resources