Page 1 of 1

Invalid Characters In check_nt for PerfMon - How To Resolve

Posted: Thu Jun 14, 2012 9:06 am
by sav2880
I've got an interesting issue that I can use some insight on.

Platform: Nagios XI 2011R2.2, VMWare Virtual Machine (in ESX), built off of the initial appliance

I am attempting to set up a service using check_nt's COUNTER functionality, for the purpose of checking the number of connections being used in an IIS app pool. I've used this to connect into PerfMon metrics many times before, but this one's a little different because the app pool's name in the background is long and uses characters that Nagios might not like using.

Here's what I have done to test thus far ... the name of the app pool is "Tools", but in the world of Perfmon, the counter for that app pool looks like this:

"\.NET Data Provider for SqlServer(_lm_w3svc_1_root_tools-3-129840746280906503[6656])\NumberOfPooledConnections"

I've attempted to test this in three places, with different results:

1) CentOS root command line - Usually when a command doesn't work in Nagios, I'll resort to checking the command from a shell prompt to make sure that the syntax is correct. To do so, the following command was run:

Code: Select all

[root@199 libexec]#  ./check_nt -H 199.231.143.66 -s NScl13nt -p 12489 -v COUNTER -l "\.NET Data Provider for SqlServer(_lm_w3svc_1_root_tools-3-129840746280906503[6656])\NumberOfPooledConnections" -w 75 -c 90
This command did successfully output a number that matched what PerfMon says. In my last test, this was "84" ... but this is the only method that has worked.

2) Nagios Service Setup - With that done, I set to enter this information using the Nagios Core Config Manager into a service. However, when I do this, Nagios always responds with 0, no matter what the actual PerfMon result was.

3) Nagios Plugin Tool Wizard - Using the tool @ http://exchange.nagios.org/directory/Ad ... ol/details, I set out to test the command noted in the command line to see if Nagios through the GUI properly recognized the command. When I did this, I get the following feedback:

Code: Select all

The Command argument $ARG1$ you provided contains invalid characters
So, this leads to two questions:

1) I can't change the name of the app pool as Perfmon sees it, so how do I resolve the "invalid characters" issue?

2) If that's not the actual reason it's failing, why would it return a proper number from a shell prompt, but not from within the Nagios GUI interface? Is there another variable I need to edit to ensure a good value is returned?

Thanks for everyone's help!

Re: Invalid Characters In check_nt for PerfMon - How To Reso

Posted: Thu Jun 14, 2012 9:26 am
by scottwilkerson
In your $ARGn$ field where you are placing the counter name, try wrapping it in single quotes

ie, for the standard "check_nt" command, make $ARG1$

Code: Select all

-l "\.NET Data Provider for SqlServer(_lm_w3svc_1_root_tools-3-129840746280906503[6656])\NumberOfPooledConnections"

Re: Invalid Characters In check_nt for PerfMon - How To Reso

Posted: Thu Jun 14, 2012 9:55 am
by sav2880
I actually had been using the check_xi_service_nsclient template, as the default check_nt one was saying NSClient was not receiving the correct password (likely that I don't know the best place to define the $USERx$ fields). So, with that one, the template is:

$USER1$/check_nt -H $HOSTADDRESS$ -s "$ARG1$" -p 12489 -v $ARG2$ $ARG3$ $ARG4$

With $ARG1 being my password for NSClient, $ARG2$ being COUNTER, and $ARG3$ being:

Code: Select all

-l "\.NET Data Provider for SqlServer(_lm_w3svc_1_root_tools-3-129840746280906503[6656])\NumberOfPooledConnections" -w 75 -c 90
Quotes look like they're in there okay, but this is the command that always returns zero, even though perfmon would contend that there is a number in here between 1 and 100 (active server, max for the pool is 100)

Do I need to add an extra variable or flag in $ARG3$ to get it to play right?

Re: Invalid Characters In check_nt for PerfMon - How To Reso

Posted: Thu Jun 14, 2012 10:03 am
by scottwilkerson
This looks fine except I would recommend trying with single quotes, not double quotes, so for $ARG3$

Code: Select all

-l '\.NET Data Provider for SqlServer(_lm_w3svc_1_root_tools-3-129840746280906503[6656])\NumberOfPooledConnections' -w 75 -c 90

Re: Invalid Characters In check_nt for PerfMon - How To Reso

Posted: Thu Jun 14, 2012 10:43 am
by sav2880
... and upon doing more research, in either single or double quotes, it runs the command and returns something .... problem is, it's returning zero. I'm running simultaneously PerfMon on the box itself and this command ... as of this exact moment, it should return 39, but no matter what, it returns zero.

Along with this, I ran this with another app pool that shows pooled connections to verify that it wasn't just a weird typo, or something strange along those lines ... same deal, should be returning a valid number (24), but is sending Nagios zero instead.

Also to make sure of no typos, I ran NSClient++ CheckSystem listpdh from the command line to ensure that it was a perfmon string that was properly recognized, which it was. Also tried adding the -t 10 to it to allow for a 10 second timeout before returning a value if it was required. Am I at the point that I'm looking at a possible bug with NSClient?

Re: Invalid Characters In check_nt for PerfMon - How To Reso

Posted: Thu Jun 14, 2012 1:48 pm
by scottwilkerson
The more I look at this it is possible that it could have to do the the () in the name, nagios cfg's don't like these...

lets go back to the double quotes and try escaping the () like this

Code: Select all

-l "\.NET Data Provider for SqlServer\(_lm_w3svc_1_root_tools-3-129840746280906503[6656]\)\NumberOfPooledConnections" -w 75 -c 90
Also, you might want to take a look at the service .cfg file in /usr/local/nagios/etc/services/ for this to see if it is all there correctly