Nagios XI: escaping () in service args

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gurkakrieg
Posts: 15
Joined: Mon Sep 09, 2013 5:43 pm

Nagios XI: escaping () in service args

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XI: escaping () in service args

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
gurkakrieg
Posts: 15
Joined: Mon Sep 09, 2013 5:43 pm

Re: Nagios XI: escaping () in service args

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios XI: escaping () in service args

Post by tmcdonald »

Is it safe to close the thread now?
Former Nagios employee
rogersochieng
Posts: 7
Joined: Mon Dec 01, 2014 7:09 am

Re: Nagios XI: escaping () in service args

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios XI: escaping () in service args

Post 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!!!!!
Former Nagios employee
rogersochieng
Posts: 7
Joined: Mon Dec 01, 2014 7:09 am

Re: Nagios XI: escaping () in service args

Post 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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Nagios XI: escaping () in service args

Post 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?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
rogersochieng
Posts: 7
Joined: Mon Dec 01, 2014 7:09 am

Re: Nagios XI: escaping () in service args

Post by rogersochieng »

Yes I did. I have even created a static configuration for this as described in earlier post but this wont work
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Nagios XI: escaping () in service args

Post by Box293 »

What version of NSClient are you using on what Operating System?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked