5

I am using vnstat for first time and I am getting this error while using vnstat -d

Error: Unable to read database "/var/lib/vnstat/eth0": No such file or directory

The file in /var/lib/vnstat are

 enp1s0  wlp2s0

These are my network interfaces.

I can understand it using eth0 file but how can I changed default file to enp1s0 from eth0.

When I use sudo vnstat -u -i eth0, I get error

Error: Unable to read database "/var/lib/vnstat/eth0": No such file or directory Error: Unable to get interface "eth0" statistics. Only available interfaces can be added for monitoring.

4 Answers 4

6

The default interface is defined in the /etc/vnstat.conf file:

$ head /etc/vnstat.conf 
# vnStat 1.13 config file
##

# default interface
Interface "eth0"

# location of the database directory
DatabaseDir "/var/lib/vnstat"

# locale (LC_ALL) ("-" = use system locale)

Although you could change it there, a possibly better way is to create your own ~/.vnstatrc file and modify that:

cp /etc/vnstat.conf ~/.vnstatrc

then use an editor of your choice to change Interface "eth0" to Interface "enp1s0" in the local copy.

See man vnstat.conf for full details.

3
  • What about wireless interface
    – Prvt_Yadav
    May 2, 2018 at 12:46
  • @Debian_yadav what about it, exactly? AFAIK vnstat can only have a single default interface, it doesn't differentiate by type. You will need to choose whether you want that to be the wired or wireless one. May 2, 2018 at 12:52
  • @steeldriver vnStat has no built-in limit for the number of interfaces it supports. The Interface configuration option only defines the interface that gets shown if no other interface is specified with the -i parameter. If no parameters are given for the vnstat command then a summary of all tracked interfaces will be shown by default. May 5, 2018 at 22:53
1

I solved the issue by changing interface in the file /etc/vnstat.conf from eth0 to wlp3s0. If you don't know your network interfaces, you could get by the command ip addr.

0

Many parson answers correctly but missing one more thing

Needs to change configuration in two places /etc/vnstat.conf and HOME Directory/.vnstatrc (Ex. /home/sagar/.vnstatrc)

Change default interface from eth0 to whatever in your machine like enp1s0 or wlp2s0 or wlp3s0

In both files statment will be likeInterface "wlp3s0"

Save file and check again useing coommend vnstat -d

1
  • Welcome to AskUbuntu! It's best if you post a complete answer, since we aren't sure which other answer(s) you are referencing. For more info about our Q&A format, check out our tour
    – Nmath
    Jan 4, 2021 at 23:29
0

Please start first vnstat service. No matter if configuration (/etc/vnstat.conf or ~/.vnstatrc) is edited or NOT.

systemctl start vnstat
/etc/rc.d/init.d/vnstat start
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.