除非在 debian 7 中以 root 身份运行,否则无法运行 vnstat

除非在 debian 7 中以 root 身份运行,否则无法运行 vnstat

所以,我需要运行这个命令:

vnstat -tr 2

但作为我刚刚创建的用户,不是作为 root,作为 root 它工作正常,但作为普通用户我得到这个:

Error: Unable to get interface "eth0" statistics.
Error: Interface "eth0" not available, exiting.

在 Debian 6 上没有这个限制,我该如何删除它?听起来像是权限问题。

答案1

在我的服务器上,当我使用参数时vnstat读取:/proc/net/dev-tr

iserv ~ # strace -e trace=file vnstat -tr 2
execve("/usr/bin/vnstat", ["vnstat", "-tr", "2"], [/* 46 vars */]) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libm.so.6", O_RDONLY)        = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
open("/root/.vnstatrc", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/etc/vnstat.conf", O_RDONLY)      = 3
open("/proc/net/dev", O_RDONLY)         = 3
Sampling eth0 (2 seconds average)...open("/proc/net/dev", O_RDONLY)         =12 packets sampled in 2 seconds     
Traffic average for eth0

      rx            4 kbit/s             4 packets/s
      tx            0 kbit/s             1 packets/s

我建议你检查一下你的/proc/net/dev权限。在 Debian 6.0.7 上,它看起来像这样:

iserv ~ # ll /proc/net/dev
-r--r--r-- 1 root root 0 14. Sep 14:19 /proc/net/dev

相关内容