Page 1 of 2

Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 10:58 am
by bbackstrom
I am following a FAQ I found that mentions there are issues adding service checks with $ in the name. It states to escape and add an add'l $. My NCPA service check:

-t $_HOSTNCPA_TOKEN$ -M '/service/MSSQL\$$MEISQL3/running'

Reports; CRITICAL: Service MSSQL\\$MEISQL3 was not found

What am I missing?

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 1:03 pm
by tgriep
When using single quotes around an option, it will not escape what is between them and to use what is there literally and that will not work. Especially with $ in the names.
To fix this, edit your option from the following

Code: Select all

-t $_HOSTNCPA_TOKEN$ -M '/service/MSSQL\$$MEISQL3/running'
to

Code: Select all

-t $_HOSTNCPA_TOKEN$ -M /service/MSSQL$"$"MEISQL3/running
Save the changes and see if that fixes it for you.

What this does it to escape a $ with a $ in that option.

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 5:53 pm
by bbackstrom
Did what you suggested - now getting CRITICAL: Service MSSQL$$MEISQL3 was not found

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 5:57 pm
by bbackstrom
Even tried with the single quotes: CRITICAL: Service MSSQL$"$"MEISQL3 was not found

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 6:02 pm
by lmiltchev
What is the version of the NPCA agent that you installed on the client? Do you see the service in web UI when you go to <https://x.x.x.x:5693/api/services>?

Run the following commands from the CLI on the Nagios XI server, and show the output:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -V
/usr/local/nagios/libexec/check_ncpa.py -H <client ip> -t <token> -M '/service/MSSQL$MEISQL3/running' -v

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 6:10 pm
by bbackstrom
bbackstrom@d3:/usr/lib/nagios/plugins/contrib$ ./check_ncpa.py -H 10.0.95.27 -t Xiq3Tosutcc4XpL -M '/service/MSSQL$MEISQL3/running' -v
Connecting to: https://10.0.95.27:5693/api/service/MSS ... pL&check=1
File returned contained:
{
"value": {
"returncode": 0,
"stdout": "OK: Service MSSQL$MEISQL3 is running"
}
}
OK: Service MSSQL$MEISQL3 is running

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 6:13 pm
by bbackstrom
bbackstrom@d3:/usr/lib/nagios/plugins/contrib$ ./check_ncpa.py -V
check_ncpa.py, Version 0.3.5

Re: Problem with adding service check in XI with $

Posted: Mon Jan 30, 2017 6:14 pm
by bbackstrom
V 1.8.1 on client

Re: Problem with adding service check in XI with $

Posted: Tue Jan 31, 2017 10:34 am
by lmiltchev
If the check below "works" (with no escaping):

Code: Select all

/usr/lib/nagios/plugins/contrib$ ./check_ncpa.py -H 10.0.95.27 -t Xiq3Tosutcc4XpL -M '/service/MSSQL$MEISQL3/running'
why are you trying to escape the dollar sign?

Go to the CCM->Services-><your service>->Edit->Common Settings, and make sure you have the following in the $ARG1$ field:

Code: Select all

-t 'Xiq3Tosutcc4XpL' -P 5693 -M '/service/MSSQL$MEISQL3/running'
Save and apply configuration.

Go to Home->Service Detail, click on the service in question, and force an immediate check. Did you get the expected result?

Re: Problem with adding service check in XI with $

Posted: Tue Jan 31, 2017 11:47 am
by bbackstrom
The cli is different since it's the shell processing the arguments - it returns OK

I need to escape for the nagios process in CCM. It sees the $ as something else (a variable maybe?). I saw this in an article in your forums. If I add to CCM with the same syntax as CLI, it hoses everything.