Say you have an /etc/fstab
file with an entry for bind
:
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
** /root/special/folder /home/user1/folder none bind 0 0
If you run the nagios
nrpe
command (below) as root
everything works fine:
/usr/lib64/nagios/plugins/check_disk -w 8% -c 5% -A -x /dev/shm -X nfs -X bind -i /boot
However, when you run this as the nagios
user it fails (as is expected since the nagios
does not have access to this folder):
sudo -u nagios /usr/lib64/nagios/plugins/check_disk -w 8% -c 5% -A -x /dev/shm -X nfs -X bind -i /boot
DISK CRITICAL - /home/user1/folder is not accessible: Permission denied
Since the nrpe
checks are done with nagios
a solution is needed. You could exclude the path specifically, using the -x
flag:
`-x /home/user1/folder`
But you’d have to do that each time you make any changes to the /etc/fstab
file.
In the commands above I left in the -X bind
flag, which I attempted, although it does not work. I also tried -X bindfs
with no luck.
There are some other flags for different types of file systems.
-X tmpfs
-X devpts
-X sysfs
-X proc
-X binfmt_misc
-X rpc_pipefs
-X nfs
These can also be written as:
--exclude-type=tmpfs
--exclude-type=devpts
--exclude-type=sysfs
--exclude-type=proc
--exclude-type=binfmt_misc
--exclude-type=rpc_pipefs
--exclude-type=nfs
However, the one that is needed to exclude the bind
is actually the none
file system, or -X none
or --exclude-type=none