Page 1 of 2

Trouble pulling Windows counter data

Posted: Thu Aug 04, 2016 7:08 pm
by gormank
Hi,
I have the below service defined and you can see that running the check as nagios in the shell, it returns data. When the service runs, it barfs up the following. Any hints on getting the syntax right? I've tried many different combinations of escape for the $ and \ chars and quoting to no avail. Waa!

NSClient - ERROR: Invalid return from command: check_pdh

Code: Select all

[nagios@lnag001 ~]$ /usr/local/nagios/libexec/check_nt -H host -s "passwd" -p 12489 -v COUNTER -l "\\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio"
58

Code: Select all

define service {
        service_description             DB_Log_Cache_Hit_Ratio_NP_RADIUS
        use                             default_service
        hostgroup_name                  MS_SQL_Servers
        check_command                   check_xi_service_nsclient!passwd!COUNTER!-l "\\MSSQL$QA4:Databases(NP_RADIUS)\Log Cache Hit Ratio"!!!!!
        check_interval                  1
        register                        1
        }
An example of a working counter service:

Code: Select all

define service {
        service_description             DB_Cache_Hit
        use                             default_service
        hostgroup_name                  MS_SQL_Servers
        check_command                   check_xi_service_nsclient!passwd!COUNTER!-l "\\Database(svchost)\Database Cache % Hit"!!!!!
        check_interval                  1
        register                        1
        }
On the one that works, I've used both \ and \\ in front of the counter and it doesn't seem to mind either one.

Code: Select all

 COUNTER =
  Check any performance counter of Windows NT/2000.
        Request a -l parameters with the following syntax:
        -l "\\<performance object>\\counter","<description>
        The <description> parameter is optional and is given to a printf
  output command which requires a float parameter.
  If <description> does not include "%%", it is used as a label.
  Some examples:
  "Paging file usage is %%.2f %%%%"
  "%%.f %%%% paging file used."

Re: Trouble pulling Windows counter data

Posted: Thu Aug 04, 2016 7:46 pm
by Box293
Try with single quotes and \$$ :

-l '\\MSSQL\$$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio'

This article talks about services but is about the $ sign.
https://support.nagios.com/kb/article.php?id=168

Re: Trouble pulling Windows counter data

Posted: Fri Aug 05, 2016 2:55 pm
by gormank
I need to start w/ those KB pages rather than posing here... Thanks!

Single quotes fail from the shell and Nagios. All of the below fail.

-l '\\MSSQL\$$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio'
-l '\\MSSQL$$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio'
-l "\\MSSQL$$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio"

But the following works, yay!

-l "\\MSSQL\$$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio"

Now I just need for it to save some perfdata...

Re: Trouble pulling Windows counter data

Posted: Fri Aug 05, 2016 5:05 pm
by gormank
I added the description bit and get perfdata, but the value is no longer in the text returned before the pipe character |... Careful what you wish for.

check_nt -H wsql002 -s "passwd" -p 12489 -v COUNTER -l "\\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio","NP_RADIUS log cache hit ratio %%"

NP_RADIUS log cache hit ratio % | 'NP_RADIUS log cache hit ratio %%'=59.000000%;0.000000;0.000000;

Re: Trouble pulling Windows counter data

Posted: Mon Aug 08, 2016 2:20 am
by Box293
gormank wrote:check_nt -H wsql002 -s "passwd" -p 12489 -v COUNTER -l "\\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio","NP_RADIUS log cache hit ratio %%"
Try %.f:

Code: Select all

check_nt -H wsql002 -s "passwd" -p 12489 -v COUNTER -l "\\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio","NP_RADIUS log cache hit ratio %.f"
check_nt --help has this information:
COUNTER =
Check any performance counter of Windows NT/2000.
Request a -l parameters with the following syntax:
-l "\\<performance object>\\counter","<description>
The <description> parameter is optional and is given to a printf
output command which requires a float parameter.
If <description> does not include "%%", it is used as a label.
Some examples:
"Paging file usage is %%.2f %%%%"
"%%.f %%%% paging file used."

Re: Trouble pulling Windows counter data

Posted: Tue Aug 09, 2016 8:46 am
by spurrellian
What version of NSClient are you using?

I would try check_nrpe instead of check_nt

It should look something like this

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter: Cache Hit Ratio=\\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\\Cache Hit Ratio"

Re: Trouble pulling Windows counter data

Posted: Tue Aug 09, 2016 10:03 am
by gormank
Heh, I actually set up to use check_nrpe yesterday and while it now returns the value as part of the status, it appends the word none to the end of the output.

# /usr/local/nagios/libexec/check_nrpe -H host-c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio"
OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 60|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=60;0;0

I can add a custom label w/ ...Counter:Custom label=... amd the none is still there.

Re: Trouble pulling Windows counter data

Posted: Tue Aug 09, 2016 10:36 am
by mcapra
Very strange. This might be a bug with NSClient++. Looking at the CheckSystem::checkCounter function:

Code: Select all

request.add_arguments("perf-config=*(suffix:none)");
This is the only place I can imagine the 'none' being appended to the perfdata output. No idea what purpose it serves though :p

Re: Trouble pulling Windows counter data

Posted: Tue Aug 09, 2016 11:20 am
by gormank
You can make a career out of trying to get the check_nt check_nrpe syntax right...

# /usr/local/nagios/libexec/check_nrpe -H qa4am2mwsql001 -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio" 'perf-config=*(suffix:none)'
OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 64|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=64;0;0

# /usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio" 'perf-config=*(suffix:)'
OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 64|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=64;0;0

# /usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio" "perf-config=*(suffix:)"

OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 64|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=64;0;0

# /usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio","perf-config=*(suffix:)"
Failed to poll counter: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio,perf-config=*(suffix:) PdhAddCounter failed: c0000bb9: The specified counter could not be found.

# /usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio" "perf-config=*(suffix:Test)"
OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 64|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=64;0;0

# /usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio" 'perf-config=*(suffix:Test)'
OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 64|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=64;0;0

# /usr/local/nagios/libexec/check_nrpe -H host -c CheckCounter -a "Counter=\MSSQL\$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio" 'perf-config=(suffix:Test)'
OK: \MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Ratio = 64|'\MSSQL$QA4:Catalog Metadata(NP_RADIUS)\Cache Hit Rationone'=64;0;0

Re: Trouble pulling Windows counter data

Posted: Tue Aug 09, 2016 11:30 am
by mcapra
It's entirely possible, for the CheckCounter command, that the underlying C is overwriting the perf-config argument.