I just simulated what you are doing and I did get the plugin to work running under the NRPE agent as the tomcat user.
What I did was set the plugin to be read - write - executable by eveyone.
Run this as root
Code: Select all
chmod 777 /usr/local/nagios/libexec/check_jvm
I added these 2 entries in the /etc/sudoers file
Code: Select all
nagios ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/check_jvm
tomcat8 ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/check_jvm
I put the JvmInspector.jar file in the /usr/local/bin folder.
I defined my command like this in the nrpe.cfg file.
Code: Select all
command[check_tomcat_threads]=/usr/bin/sudo -u tomcat8 /usr/local/nagios/libexec/check_jvm -n org.apache.catalina.startup.Bootstrap -p threads -w 195 -c 225
Restarted the NRPE agent and tested it like this and it worked.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_tomcat_threads
OK 18 |threads=18;;;
Then I tested it from the Nagios server and it worked there as well
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H centos7 -c check_tomcat_threads
OK 17 |threads=17;;;
Try and duplicate the settings and see if it works.
If it fails, I will need to see the full /etc/sudoers file to see if there are any other entries blocking the plugin.
Also run the following on the tomcat server and post the output.
Code: Select all
ls -l /usr/local
ls -l /usr/local/nagios/libexec
ls -l /usr/local/nagios/libexec/check_jvm
ls -l /usr/local/bin
Let us know the outcome