错误:无法读取数据库“/var/lib/vnstat/eth0”:没有那个文件或目录

Prv*_*dav 5 networking vnstat

我是vnstat第一次使用,使用时出现此错误vnstat -d

错误:无法读取数据库“/var/lib/vnstat/eth0”:没有那个文件或目录

里面的文件/var/lib/vnstat

 enp1s0  wlp2s0
Run Code Online (Sandbox Code Playgroud)

这些是我的网络接口。

我可以使用eth0file来理解它,但是如何将默认文件更改为enp1s0from eth0.

当我使用时sudo vnstat -u -i eth0,我收到错误

错误:无法读取数据库“/var/lib/vnstat/eth0”:没有那个文件或目录错误:无法获取接口“eth0”统计信息。只能添加可用接口进行监控。

ste*_*ver 6

默认接口在/etc/vnstat.conf文件中定义:

$ 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)
Run Code Online (Sandbox Code Playgroud)

尽管您可以在那里更改它,但可能更好的方法是创建自己的~/.vnstatrc文件并对其进行修改:

cp /etc/vnstat.conf ~/.vnstatrc
Run Code Online (Sandbox Code Playgroud)

然后使用您选择的编辑器更改Interface "eth0"Interface "enp1s0"本地副本。

请参阅man vnstat.conf完整的详细信息。