最近,我注意到,当用非root用户运行时,我的监控networking的脚本没有任何显示。
我的脚本只是看/proc/net/dev
,它具有以下权限(444):
-r--r--r-- 1 root root 0 Feb 26 09:31 dev
但是,即使每个人都有读取权限,我注意到非root用户无法获取任何数据
> cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 dummy0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bond0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ip6tnl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 tunl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
当我添加sudo命令这里是我得到的结果
> sudo cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed eth0: 69684609 360869 0 0 0 0 0 234060 419896366 484740 0 0 0 0 0 0 eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 dummy0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 bond0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ip6tnl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lo: 113595057 801133 0 0 0 0 0 0 113595057 801133 0 0 0 0 0 0 tunl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
我有兴趣知道为什么/ proc / net / dev有这种行为?
顺便说一下,我的服务器正在使用Debian 8.3(Jessie)。
正如在这个链接中所述: https : //stackoverflow.com/questions/8955724/regular-user-cant-read-proc-net-dev
您的内核可能使用了grsec编译选项,这会阻止您访问统计信息。 你应该尝试使用另一个内核。