Check_JVM - Check_nrpe Connection Set by Peer

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.
Locked
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Check_JVM - Check_nrpe Connection Set by Peer

Post by cybergene »

So I was trying out Check_jvm for monitoring Java thread and Heap and I came across this posting:
https://support.nagios.com/forum/viewto ... 30#p238851

I followed the same steps and I managed to pass the initial error

Code: Select all

UNKNOWN Can't connect to the JVM
and Now when I try to run the command similar to what the post says, I get the following error

Code: Select all

./check_nrpe -H localhost -c check_jvm_threads
CHECK_NRPE: Error - Could not connect to ::: Connection reset by peer
check_jvm has chmod 777
sudoers file has been updated

My nrpe.cfg has the following commands:

Code: Select all

allowed_hosts=127.0.0.1,<nagios_server_ip>

# check_jvm
command[check_jvm_threads]=/usr/bin/sudo -u jenkins /usr/local/nagios/libexec/check_jvm -n remoting.jar -p threads -w 195 -c 225
Checking the java processes running :

Code: Select all

ps aux | grep java
ec2-user 10254  0.0  0.0 112712   972 pts/0    S+   13:42   0:00 grep --color=auto java
jenkins  16361  0.0  0.0 113184  1580 ?        Ss   Nov08   0:00 bash -c cd "/home/jenkins" && java  -jar remoting.jar -workDir /home/jenkins
jenkins  16370  0.6  1.8 7797188 291688 ?      Sl   Nov08  53:17 java -jar remoting.jar -workDir /home/jenkins
checking the JVM for Jenkins with the JavaInspector:

Code: Select all

sudo su - jenkins -c "java -jar /usr/local/bin/JvmInspector.jar all"

JVM pid: 16370
  name: remoting.jar -workDir /home/jenkins
  thread count: 27 (peak: 223)
  class count: 5266
  heap memory: max=3659530240|commited=115867648|used=71438600
  non-heap memory: max=-1|commited=61997056|used=58888112
  java version: 1.8.0_232 (Oracle Corporation)
  java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el7_7.x86_64/jre
  jvm arguments: []
  class path: remoting.jar
Any help is appreciated!
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by benjaminsmith »

Hello @cybergeen,

Well, it looks like it's close. Have you opened port 5666 for NRPE in the firewall?

1. Run the following on the remote host and post the output.

Code: Select all

./check_nrpe -H 127.0.0.1
2. Do you know if NRPE is installed as a daemon or running under xinetd? The allowed host configuration is different for each type of installation. Post output of the following command. Thanks.

Code: Select all

cat /etc/xinetd.d/nrpe
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by cybergene »

Hi @benjaminsmith

It doesn't seem closed to me.


The command return a good result

Code: Select all

./check_nrpe -H 127.0.0.1
NRPE v3.2.1
And the service is running as as daemon:

Code: Select all

sudo systemctl status nrpe
● nrpe.service - Nagios Remote Plugin Executor
   Loaded: loaded (/usr/lib/systemd/system/nrpe.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-11-13 20:47:05 UTC; 6 days ago
     Docs: http://www.nagios.org/documentation
  Process: 6252 ExecStopPost=/bin/rm -f /usr/local/nagios/var/nrpe.pid (code=exited, status=0/SUCCESS)
 Main PID: 6256 (nrpe)
   CGroup: /system.slice/nrpe.service
           └─6256 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -f
Other commands aon this Linux box are running well, (CPU and Memory..). It is only this command with the check_jvm that doesn't work.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by benjaminsmith »

Hello @cybergene,

Ok. Let's try and get this worked out. Are you able to run the plugin locally on the remote host? Log in as the nagios user, and run the check command.

Code: Select all

su - nagios
/usr/bin/sudo -u jenkins /usr/local/nagios/libexec/check_jvm -n remoting.jar -p threads -w 195 -c 225
What are the permissions on the plugin?

Code: Select all

ls -l /usr/local/nagios/libexec/check_jvm
Can you post your sudoers file for us to review? Thanks.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by cybergene »

Hello @benjaminsmith,
Sorry for the late reply but I was busy at work, here are the results of the commands you asked for:

Log in as the nagios user, and run the check command

Code: Select all

[nagios@ip-xx-xxx-x-xx libexec]$ /usr/bin/sudo -u jenkins /usr/local/nagios/libexec/check_jvm -n remoting.jar -p threads -w 195 -c 225
UNKNOWN Can't connect to the JVM:
Permission for the check_jvm plugin

Code: Select all

[nagios@ip-xx-xxx-x-xx libexec]$ ls -l /usr/local/nagios/libexec/check_jvm
-rwxrwxrwx. 1 nagios nagios 5981 Nov 13 19:58 /usr/local/nagios/libexec/check_jvm
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by tgriep »

You are trying to run the plugin as the jenkins user so there has to be some permission changes/

Edit the /etc/sudoers file and make sure the following entry it there.

Code: Select all

jenkins ALL=(ALL) NOPASSWD: /usr/local/nagios/libexec/check_jvm
Another thing, the permissions of the plugin is set, the folder may be restricting the jenkins user.
Try editing the /etc/groups file and add the jenkins user to the nagios group and see if that works.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by cybergene »

I already have added that to the sudoers file and it still not working.

I tried changing the owner of the libexec/ to Jenkins user and it still can't connect to JVM

Code: Select all

$ sudo chown jenkins:jenkins libexec/
$ /usr/bin/sudo -u jenkins /usr/local/nagios/libexec/check_jvm -n remoting.jar -p threads -w 195 -c 225
UNKNOWN Can't connect to the JVM:
is there something specific about this plugin? Do you suggest any other plugin to monitor JVM ? A plugin that you know it works?
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by tgriep »

Open up the plugin and see is it is using any applications to gather the data it requires.
Make sure the applications have the full path to them as the jenkins user may have a different default path set.

Also, the jenkins user has to have permissions to run those applications as well.
You would have to add that to the sudoers file.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cybergene
Posts: 92
Joined: Wed Aug 10, 2016 7:38 am
Location: Ottawa, Ontario, Canada

Re: Check_JVM - Check_nrpe Connection Set by Peer

Post by cybergene »

It did not work for me- same error, anyways you can close this for now. It is not a high priority now. If I have more questions I'll let you know.

Thank you!
Locked