Page 2 of 3

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Mon Oct 12, 2015 2:25 pm
by kvaldez
Hi,

This is what I got when putting single quotes to '$ARG3':
Image1.jpg
I've tried the same way with the other ARG but I'm getting the same output.

I think the problem is around here, this is the check_jmx.sh file located in /usr/local/nagios/libexec

Code: Select all

#!/bin/sh
#
# Nagios JMX plugin.
#

JAVA_CMD=`which java`

if [ -z $JAVA_CMD ]
then

  if [ -x $JAVA_HOME/bin/java ]
  then
    JAVA_CMD=$JAVA_HOME/bin/java
  else
    echo JMX CRITICAL - java not found.
    exit 2
  fi

fi

DIR=`dirname $0`
$JAVA_CMD -jar $DIR/check_jmx.jar "$@"
As you can see the error Im getting from the Try Command is there

Code: Select all

JMX CRITICAL - java not found.
-kvaldez

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Mon Oct 12, 2015 2:38 pm
by hsmith
If you read through the comments here, have you made any of the tweaks listed there? Apparently this plugin has some known issues.

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Mon Oct 12, 2015 7:18 pm
by Box293
hsmith wrote:First thing to point out here would be that the test check command is VERY buggy. I would not use it, as it has issues with special characters. What is the error on the service detail screen?
I would like to re-iterate what @hsmith has said here. Testing the JMX plugin via the Test Check Command button is going to cause you no end of headaches. You MUST follow this method:
  • Make any changes
    Save and Apply Config
    Schedule Immediate Check of the service to perform a test

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Tue Oct 13, 2015 9:32 am
by kvaldez
Hi guys,

Thanks to all for your help. Checking on other servers running nagios I found that the same plugin was running without problems on an older version of Nagios XI.

Not sure but im guessing this issue have something to do with the version.

In order to make the plugin work correctly I'll have to use this older Nagios XI version.

Here are some screenShots.

Newer Version:
Pic1.jpg
Version:
Pic2.jpg
Older Version:
Pic3.jpg
If someone has any comment please let me know. If not I think I'll be ok to close this case.

-kvaldez

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Tue Oct 13, 2015 1:59 pm
by hsmith
We are going to need screenshots/output from something other than the test screen as you've provided here.
Box293 wrote:
hsmith wrote:First thing to point out here would be that the test check command is VERY buggy. I would not use it, as it has issues with special characters. What is the error on the service detail screen?
I would like to re-iterate what @hsmith has said here. Testing the JMX plugin via the Test Check Command button is going to cause you no end of headaches. You MUST follow this method:
  • Make any changes
    Save and Apply Config
    Schedule Immediate Check of the service to perform a test


I would also like some elaboration on this point:

hsmith wrote:If you read through the comments here, have you made any of the tweaks listed there? Apparently this plugin has some known issues.
Also, have you read through this document?

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Tue Oct 13, 2015 3:24 pm
by kvaldez
Hi,

This is the screen you're asking on the first point.

Home -> Service Detail
pic.png
Sencond as I said, the same plugin worked on the older nagios version, But when installing the same plugin on the newer one the error comes out.

Third, yes I have read the document https://assets.nagios.com/downloads/nag ... ios-XI.pdf , this guide is what help me installing JMX for nagios Nagios XI 2014R2.7, and its working right now.

-kvaldez

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Tue Oct 13, 2015 3:35 pm
by hsmith
hsmith wrote:If you read through the comments here, have you made any of the tweaks listed there? Apparently this plugin has some known issues.


Have you made any of the modifications to the plugin listed here? I can't think of anything we changed in XI5 that would have broke this plugin..

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Tue Oct 13, 2015 3:57 pm
by kvaldez
No I haven't.

It seems very strange to me too. But this is the only different between both enviroments where im running nagios XI.

-kvaldez

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Tue Oct 13, 2015 6:09 pm
by Box293
Basically what is happening is the plugin cannot find the java executable when it runs as the nagios user. Its something to do with the nagios user account not getting it's environment loaded or something technical like that.

If I'm correct, the /usr/local/nagios/libexec/check_jmx plugin is defined as:

Code: Select all

#!/bin/sh
#
# Nagios plugin to monitor Java JMX (http://java.sun.com/jmx)attributes.
#
RDIR=`dirname $0`
java -cp $RDIR/jmxquery.jar org.nagios.JMXQuery $@
Try changing java to the specific location of the java executable. First find it:

Code: Select all

which java
Lets assume it is in /usr/bin/java

Then update the plugin as follows:

Code: Select all

#!/bin/sh
#
# Nagios plugin to monitor Java JMX (http://java.sun.com/jmx)attributes.
#
RDIR=`dirname $0`
/usr/bin/java -cp $RDIR/jmxquery.jar org.nagios.JMXQuery $@
Does this help?

Re: Nagios XI 5R1.0 JMX Not Working

Posted: Mon Oct 19, 2015 4:49 pm
by kvaldez
Hi,

Im really sorry for the delay, I was sick this days.

Anyway I tried what you said but looking at the script I found that first the jmx shell finds where is JAVA installed so then it can pass that value to other variables inside the shell

Code: Select all

#!/bin/sh
#
# Nagios JMX plugin.
#

JAVA_CMD=`which java`
The output of which java in my server is this:

Code: Select all

/usr/java/jdk1.7.0_79/bin/java
So I just need to change this on the script:

Code: Select all

#!/bin/sh
#
# Nagios JMX plugin.
#

JAVA_CMD=/usr/java/jdk1.7.0_79/bin/java
The result:
Result.png
Thanks to all of you guys, you really save me on this one.

PD: Please mark this case as solved

-kvaldez