Page 1 of 1

Nagios XI: escaping () in service args

Posted: Mon Jan 27, 2014 11:22 pm
by gurkakrieg
I'm setting up some nsclient++ nrpe checks against Windows 2012 servers, specifically checking some performance counters. I want to set this up as a new service on the Service Management screen. I'm using "check_nrpe" and passing in "CheckCounter" as $ARG1$, and the "-a" string as $ARG2$.

If I check a perfmon without parentheses, everything is fine (although the back slashes are escaped unnecessarily).

If I check a perfmon with parentheses, the call fails. Here is an example command, provided by the "Test Check Command" dialog:

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_nrpe -H my_host_name -t 30 -c CheckCounter -a "Counter:proc=\\Processor Information\(_Total\)\\% Processor Time"
As you can see, the parentheses are escaped, and this breaks the call. Running nsclient++ in test mode, I get the following error:

Code: Select all

\CheckSystem.cpp:1517 ERROR: Counter not found: \Processor Information\(_Total\)\% Processor Time: -1073738823: The specified counter could not be found.
If I make the same call from the Linux shell, using my original command, it works. For reference, here is my original command:

Code: Select all

./check_nrpe -H my_host_name -t 30 -c CheckCounter -a "Counter:proc=\Processor Information(_Total)\% Processor Time"
I've tried single vs double quotes and have toggled on and off "allow nasty characters" in the nsclient.ini


Is there a way to tell XI not to escape the parentheses?

I am using the Nagios XI trial 2012R2.8c and nsclient++ version NSCP-0.4.1.102-x64.

Thanks.


000000014033E2C0, Version: 000000014033E268, Platform: 000000014033E238

Re: Nagios XI: escaping () in service args

Posted: Tue Jan 28, 2014 3:02 pm
by abrist
Just a heads up - the "Test Check Command" option in the CCM may have escaping issues with certain checks. Have you tried just configuring the check, and then applying configuration and allowing XI to perform the check normally?

Re: Nagios XI: escaping () in service args

Posted: Tue Jan 28, 2014 4:08 pm
by gurkakrieg
Yep, I finally figured that out, lol.

I ran the check from the shell, made sure it worked, saved it as a service, then invoked it manually. Worked like a charm.

Thanks.

Re: Nagios XI: escaping () in service args

Posted: Tue Jan 28, 2014 4:15 pm
by tmcdonald
Is it safe to close the thread now?

Re: Nagios XI: escaping () in service args

Posted: Tue Dec 02, 2014 3:45 pm
by rogersochieng
I am having same issue where below is working in shell but not in CCM
/usr/local/nagios/libexec/check_nrpe -H 192.168.170.111 -p 5666 -c CheckCounter -a "\\MSSQL\$LYNCARC:Resource Pool Stats(*)\\CPU usage %" ShowAll MaxWarn=10 MaxCrit=20

i get good output
OK: \MSSQL$LYNCARC:Resource Pool Stats(*)\CPU usage %: 0|'\MSSQL$LYNCARC:Resource Pool Stats(*)\CPU usage %'=0;10;20


I went in static folder and created below configuration

define service {
host_name 192.168.170.111
service_description Resource Pool Stats
check_command check_nrpe_win_counter!"\\MSSQL\$LYNCARC:Resource Pool Stats(*)\\CPU usage %"!100!300!!!!!
max_check_attempts 10
check_interval 3
retry_interval 5
register 1
}


I get below error

CRIT: Counter not found: \MSSQL$LYNCARC:Resource Pool Stats(*)\CPU usage %$: -1073738823: The specified counter could not be found.

Re: Nagios XI: escaping () in service args

Posted: Tue Dec 02, 2014 3:54 pm
by tmcdonald
Try double-escaping the backslashes like so:

Code: Select all

check_command check_nrpe_win_counter!"\\\\MSSQL\$LYNCARC:Resource Pool Stats(*)\\\\CPU usage %"!100!300!!!!!

Re: Nagios XI: escaping () in service args

Posted: Tue Dec 02, 2014 4:06 pm
by rogersochieng
If I double escape I get below error

RIT: Counter not found: \\MSSQL$LYNCARC:Resource Pool Stats(*)\\CPU usage %$: -2147481648: Unable to connect to the specified computer or the computer is offline.

Re: Nagios XI: escaping () in service args

Posted: Tue Dec 02, 2014 4:35 pm
by sreinhardt
I am having same issue where below is working in shell but not in CCM
This is to be expected when using the test command button from the UI. The test command button executes very differently from how nagios does natively. Have you tried saving that config and having nagios execute it instead of attempting to execute from test command button?

Re: Nagios XI: escaping () in service args

Posted: Tue Dec 02, 2014 5:06 pm
by rogersochieng
Yes I did. I have even created a static configuration for this as described in earlier post but this wont work

Re: Nagios XI: escaping () in service args

Posted: Tue Dec 02, 2014 6:19 pm
by Box293
What version of NSClient are you using on what Operating System?