NRPE: UNKNOWN Can't connect to the JVM

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
pmoradiya
Posts: 26
Joined: Fri Oct 06, 2017 9:48 am

Re: NRPE: UNKNOWN Can't connect to the JVM

Post by pmoradiya »

Thanks @npolovenko. I also agree with you.

I tried changing tomcat8 user with /bin/bash shell access and restarted nrpe. Unfortunately the result didn't change.

Code: Select all

tomcat8:x:112:116::/usr/share/tomcat8:/bin/bash

Code: Select all

# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_tomcat_threads
UNKNOWN Can't connect to the JVM:
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE: UNKNOWN Can't connect to the JVM

Post by tgriep »

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
Be sure to check out our Knowledgebase for helpful articles and solutions!
pmoradiya
Posts: 26
Joined: Fri Oct 06, 2017 9:48 am

Re: NRPE: UNKNOWN Can't connect to the JVM

Post by pmoradiya »

Thanks @tgriep for the detailed information and sharing simulation results.

Coincidentally, NRPE started working through the same NRPE cleanup steps (https://support.nagios.com/kb/article/n ... tml#Ubuntu) and installation steps that I had run previously (many times).

I still don't know what the cause could be. But what I have noticed is, the same steps don't guarantee the NRPE will work on the new host (with exact same configuration as other hosts).

Will really appreciate your feedback on this.

Thanks.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE: UNKNOWN Can't connect to the JVM

Post by tgriep »

I am guessing it is a permission problem you are having with the plugin and also the settings in the sudoers file has to have both the nagios user and the tomcat user set for the plugin like my example.

The NRPE packages that are created by other people have different settings so the user accounts and permissions will have to be modified to match.

Just remember, the NRPE agent runs as the nagios user account when using the source installer instructions and the nagios user needs to sudo to the tomcat user to run the plugin.
If that doesn't work, you would get the error you are receiving.
Be sure to check out our Knowledgebase for helpful articles and solutions!
pmoradiya
Posts: 26
Joined: Fri Oct 06, 2017 9:48 am

Re: NRPE: UNKNOWN Can't connect to the JVM

Post by pmoradiya »

Ya. I agree with your notes here.
Thanks a lot for all the support to get through this issue. I think this thread can be closed.
kyang

Re: NRPE: UNKNOWN Can't connect to the JVM

Post by kyang »

Closing this thread.

If you have any more questions, feel free to create another thread.

Thanks for using the Nagios Support Forum!
Locked