Page 1 of 1

Nagios remote nrpe check_disk returns permission denied

Posted: Fri Jun 16, 2017 6:10 am
by sinaowolabi
Hi!

I have a problem with remote check_disk command using check_disk.
The remote server (RHEL 7.2) has nrpe installed and when I run check_disk locally, I get correct response:
/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -A -X configfs -X cgroup -X tmpfs -X selinuxfs -X sysfs -X proc -X mqueue -X binfmt_misc -X devtmpfs
DISK OK - free space: / 7231 MB (25% inode=92%); /boot 266 MB (62% inode=99%); /tmp 9387 MB (99% inode=99%); /var/log 95114 MB (99% inode=99%); /dataspace 87398 MB (22% inode=99%); /var/lib/docker/devicemapper 7231 MB (25% inode=92%);

But trying to run it from nagios server via nrpe returns:
/usr/lib64/nagios/plugins/check_nrpe -H server -c check_hda1
DISK CRITICAL - /var/lib/docker/devicemapper/mnt/39f72d56797955d3a4d9c21221b6da1ef3b98d0b165d89dd371cc70e80908009 is not accessible: Permission denied

Ive disabled SELinux on the remote server, Ive added permissions via sudo to allow nrpe and nagios user commands to run:
User_Alias NRPERS = nagios, nrpe
Cmnd_Alias NRPERSCOMMANDS = /usr/lib64/nagios/plugins/eventhandlers/fix_ipsec, /usr/bin/docker inspect *, /usr/lib64/nagios/plugins/check-docker-container.sh *
Defaults:NRPERS !requiretty
NRPERS ALL=(root) NOPASSWD: NRPERSCOMMANDS



Please what could be the problem?

Re: Nagios remote nrpe check_disk returns permission denied

Posted: Fri Jun 16, 2017 12:21 pm
by tgriep
Try adding the path to the check_disk plugin to your Cmmd_Alias NRPERSCOMMANDS line in your /etc/sudoers like the example below.

Code: Select all

Cmnd_Alias NRPERSCOMMANDS = /usr/lib64/nagios/plugins/eventhandlers/fix_ipsec, /usr/bin/docker inspect *, /usr/lib64/nagios/plugins/check-docker-container.sh *, /usr/lib64/nagios/plugins/check_disk
Also, in the nrpe command definition put the sudo command in it so when the agent runs it, it will run it as root.

Code: Select all

command[check_hda1]=/usr/bin/sudo /usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -A -X configfs -X cgroup -X tmpfs -X selinuxfs -X sysfs -X proc -X mqueue -X binfmt_misc -X devtmpfs
Both of those changes should get the check_disk to run as root and fix the error you are receiving.

Re: Nagios remote nrpe check_disk returns permission denied

Posted: Sat Jun 17, 2017 3:56 pm
by sinaowolabi
Thanks a lot, that worked!

Re: Nagios remote nrpe check_disk returns permission denied

Posted: Mon Jun 19, 2017 9:20 am
by tgriep
Your welcome, glad it is working. I'll mark the post as solved and lock it. If you have any questions in the future, feel free to open a new post.