Trouble pulling Windows counter data

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Trouble pulling Windows counter data

Post 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."
Last edited by gormank on Thu Aug 04, 2016 7:51 pm, edited 2 times in total.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Trouble pulling Windows counter data

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Trouble pulling Windows counter data

Post 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...
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Trouble pulling Windows counter data

Post 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;
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Trouble pulling Windows counter data

Post 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."
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
spurrellian
Posts: 43
Joined: Tue Jan 06, 2015 6:26 am
Location: Bath, UK

Re: Trouble pulling Windows counter data

Post 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"
Paul S - Using Nagios XI, Network Analyzer, Log Server
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Trouble pulling Windows counter data

Post 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.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Trouble pulling Windows counter data

Post 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
Former Nagios employee
https://www.mcapra.com/
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Trouble pulling Windows counter data

Post 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
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Trouble pulling Windows counter data

Post by mcapra »

It's entirely possible, for the CheckCounter command, that the underlying C is overwriting the perf-config argument.
Former Nagios employee
https://www.mcapra.com/
Locked