NRPE sudo on RHEL 8
Posted: Thu Jul 02, 2020 10:59 am
Hello. I'm trying to get NRPE 4.0.3 working correctly on RHEL 8. The part that is not working is NRPE cannot run sudo commands, which i need in order to be able to monitor Tomcat's heap.
From the Nagios XI server i just get back:
On the client, "tomcat_heap" is defined like so, using sudo:
NRPE runs as the nrpe user, and i've confirmed that by checking "ps aux". If i log in as that user, i can run the full command manually and it works great:
I've proven that sudo from the nrpe account works, but just for more info this is what is listed in the sudoers configuration:
Note that those permissions are pretty broad; i am planning on tightening it once i get things working.
The SELinux boolean "nagios_run_sudo" is on. But just to make sure that SELinux is not causing problems, i have temporararily turned it off:
If i check NRPE's output i can see "WARNING: my_system() seteuid(0): Operation not permitted". I have tried Googling for that error but not gotten any hints that fix the problem. Here's the output that shows the seteuid error:
Any ideas what else i can do to make this work?
From the Nagios XI server i just get back:
Code: Select all
# ./check_nrpe -H lnx-ethosapi2-test -u -t 30 -c tomcat_heap
UNKNOWN Can't connect to the JVM:
Code: Select all
command[tomcat_heap]=/usr/bin/sudo -u tomcat8 /usr/lib64/nagios/plugins/check_jvm -n org.apache.catalina.startup.Bootstrap -p heap -w 90 -c 101
Code: Select all
# su - nrpe
Last login: Wed Jul 1 16:20:17 CDT 2020 on pts/0
$ /usr/bin/sudo -u tomcat8 /usr/lib64/nagios/plugins/check_jvm -n org.apache.catalina.startup.Bootstrap -p heap -w 90 -c 101
OK 10% | max=6174015488;;; commited=6174015488;;; used=676489776;;;
Code: Select all
Defaults:nrpe !requiretty
nrpe ALL=(ALL) NOPASSWD: ALL
The SELinux boolean "nagios_run_sudo" is on. But just to make sure that SELinux is not causing problems, i have temporararily turned it off:
Code: Select all
# sestatus
SELinux status: disabled
Code: Select all
# systemctl status nrpe -l
Jul 02 10:51:54 lnx-ethosapi2-test.test.drake.edu nrpe[1436]: Host 10.10.3.0 is asking for command 'tomcat_heap' to be run...
Jul 02 10:51:54 lnx-ethosapi2-test.test.drake.edu nrpe[1436]: Running command: /usr/bin/sudo -u tomcat8 /usr/lib64/nagios/plugins/check_jvm -n org.apache.catalina.startup.Bootstrap -p heap -w 90 -c 101
Jul 02 10:51:54 lnx-ethosapi2-test.test.drake.edu nrpe[1437]: WARNING: my_system() seteuid(0): Operation not permitted
Jul 02 10:51:54 lnx-ethosapi2-test.test.drake.edu sudo[1438]: nrpe : TTY=unknown ; PWD=/ ; USER=tomcat8 ; COMMAND=/usr/lib64/nagios/plugins/check_jvm -n org.apache.catalina.startup.Bootstrap -p heap -w 90 -c 101
Jul 02 10:51:54 lnx-ethosapi2-test.test.drake.edu nrpe[1436]: Command completed with return code 3 and output: UNKNOWN Can't connect to the JVM:
Jul 02 10:51:54 lnx-ethosapi2-test.test.drake.edu nrpe[1436]: Return Code: 3, Output: UNKNOWN Can't connect to the JVM: