Check works in command line, fails in Nagios XI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Check works in command line, fails in Nagios XI

Post 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
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post by npolovenko »

Hello, @hbouma. Please insert the escape character \ before ; in the Nagios command definition. "\;".
Let me know if that fixes your issue.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

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

Post 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;
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

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

Post 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?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

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

Post by hbouma »

That is all I needed.

Thank you
Henry
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post by npolovenko »

Closing the thread as resolved.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked