Page 1 of 1

Check works in command line, fails in Nagios XI

Posted: Thu Oct 18, 2018 11:22 am
by hbouma
I am running a check for a bitbucket java process via NCPA. The check finds the 1 running process when run from command line, but fails when running the same check in Nagios XI. We are running Nagios XI 5.4 on Red Hat 7 64bit.

HOSTNAME and TOKEN obscured for security.

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H HOSTNAME -t 'TOKEN' -P 5693 -M 'processes' -q 'name=java,cmd=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64//bin/java -classpath /opt/atlassian-bitbucket-latest/app -Datlassian.standalone=BITBUCKET -Dbitbucket.home=/bitbucket/bitbucket-home -Dbitbucket.install=/opt/atlassian-bitbucket-latest -Xms512m -Xmx1g -XX:+UseG1GC -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.io.tmpdir=/bitbucket/bitbucket-home/tmp -Djava.library.path=/opt/atlassian-bitbucket-latest/lib/native;/bitbucket/bitbucket-home/lib/native com.atlassian.bitbucket.internal.launcher.BitbucketServerLauncher start' -w 0: -c 1:1
returns 1 process found.

from the Nagios XI config, it is converting the

Code: Select all

latest/lib/native;/bitbucket/bitbucket
into

Code: Select all

latest/lib/native%3B/bitbucket/bitbucke
as I save the check configuration and returns 0 processes.

Oddly, when I test this from the service configuration screen, it seems to cut off the rest of the command after the ; in the command definition.

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H HOSTNAME -t 'TOKEN' -P 5693 -M 'processes' -q 'name=java,cmd=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64//bin/java -classpath /opt/atlassian-bitbucket-latest/app -Datlassian.standalone=BITBUCKET -Dbitbucket.home=/bitbucket/bitbucket-home -Dbitbucket.install=/opt/atlassian-bitbucket-latest -Xms512m -Xmx1g -XX:+UseG1GC -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.io.tmpdir=/bitbucket/bitbucket-home/tmp -Djava.library.path=/opt/atlassian-bitbucket-latest/lib/native

Re: Check works in command line, fails in Nagios XI

Posted: Thu Oct 18, 2018 12:46 pm
by npolovenko
Hello, @hbouma. Please insert the escape character \ before ; in the Nagios command definition. "\;".
Let me know if that fixes your issue.

Re: Check works in command line, fails in Nagios XI

Posted: Thu Oct 18, 2018 12:52 pm
by hbouma
Inserting the escape character doesn't help. Here is the output when testing it in the XI GUI. It seems as if the escape character is being considered part of the cmd.

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H HOSTNAME -t 'TOKEN' -P 5693 -M 'processes' -q 'name=java,cmd=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64//bin/java -classpath /opt/atlassian-bitbucket-latest/app -Datlassian.standalone=BITBUCKET -Dbitbucket.home=/bitbucket/bitbucket-home -Dbitbucket.install=/opt/atlassian-bitbucket-latest -Xms512m -Xmx1g -XX:+UseG1GC -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.io.tmpdir=/bitbucket/bitbucket-home/tmp -Djava.library.path=/opt/atlassian-bitbucket-latest/lib/native\;/bitbucket/bitbucket-home/lib/native com.atlassian.bitbucket.internal.launcher.BitbucketServerLauncher start' -w 0: -c 1:1
CRITICAL: Process count for processes named java was 0 | 'process_count'=0;0:;1:1;

Re: Check works in command line, fails in Nagios XI

Posted: Thu Oct 18, 2018 4:15 pm
by npolovenko
@hbouma, Please delete the forward slash and create a macro in the resource.cfg file:
$USER9$=";"
https://assets.nagios.com/downloads/nag ... Macros.pdf

Then replace ; in the command with $USER9$ and apply the configuration.

PS: This won't work in if your run a test command in the CCM, but it should work on the home screen in XI.

Re: Check works in command line, fails in Nagios XI

Posted: Fri Oct 19, 2018 9:16 am
by hbouma
That did work. Any idea why we have to use a Macro for the ; character? Is this something that will be fixed coming up?

Re: Check works in command line, fails in Nagios XI

Posted: Fri Oct 19, 2018 9:52 am
by npolovenko
@hbouma, Glad it works now. Semicolon, $ and ! are special characters used by Nagios. They have a reserved functionality when Nagios compiles commands and object definitions for internal use. As of right now, we only have a workaround with macros. Let me know if you have any other questions so far?

Re: Check works in command line, fails in Nagios XI

Posted: Fri Oct 19, 2018 10:51 am
by hbouma
That is all I needed.

Thank you
Henry

Re: Check works in command line, fails in Nagios XI

Posted: Fri Oct 19, 2018 11:40 am
by npolovenko
Closing the thread as resolved.