nrpe nsclient++ check counter - No counters specified

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
zjllee
Posts: 3
Joined: Fri Jun 10, 2016 3:41 am

nrpe nsclient++ check counter - No counters specified

Post by zjllee »

Hi I have been trying to use the check counter function via nrpe+nsclient but I keep getting a "No counters specified: add counter=<name of counter>" unknown status in Nagios. Anyone can comment on what I am doing wrong. Here're the different ways that I have tried defining the services with no luck:

check_command check_nrpe!CheckCounter!'Counter:Idle Timer=\Processor Information(_Total)\% Idle Time' Showall MaxWarn=80 MaxCritcrit=90
check_command check_nrpe!CheckCounter!'Counter:% Processor Used Core 0=\Processor(0)\% Processor Time' ShowAll MaxWarn=80 MaxCrit=90
check_command check_nrpe!CheckCounter!'Counter=\\Print Queue(Microsoft XPS Document Writer)\\Jobs' MaxWarn=5 MaxCrit=15 ShowAll

CheckSystem is enabled on the nsclient++ agent. Thank you
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: nrpe nsclient++ check counter - No counters specified

Post by lmiltchev »

Can you show us the actual command run from the command line along with the output of it?

Example:

Code: Select all

[root@localhost libexec]# ./check_nrpe -H x.x.x.x -c CheckCounter -a 'Counter:Idle Timer=\Processor Information(_Total)\% Idle Time' Showall MaxWarn=80 MaxCritcrit=90
WARNING: Idle Timer = 94|'Idle Timernone'=94;80;0
Also, show us the "check_nrpe" command definition.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: nrpe nsclient++ check counter - No counters specified

Post by rkennedy »

Also - to add to what Ludmil mentioned, I did some testing on my end. I was seeing mixed results with single quotes, but it worked with double quotes. Could you try using double quotes?

Code: Select all

[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c CheckCounter -a "Counter=\\Server\\Errors Logon"
OK: \Server\Errors Logon = 0|'\Server\Errors Logonnone'=0;0;0
[root@localhost libexec]# ./check_nrpe -H 192.168.5.47 -c CheckCounter -a 'Counter=\\Server\\Errors Logon'
Failed to poll counter: PdhCollectQueryData failed: : 800007d5: No data to return.
Former Nagios Employee
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: nrpe nsclient++ check counter - No counters specified

Post by Box293 »

This article explains how the counters need to be referenced (double slashes):

https://support.nagios.com/kb/article.php?id=126

This one explains how to add a service:

https://support.nagios.com/kb/article.php?id=127
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
zjllee
Posts: 3
Joined: Fri Jun 10, 2016 3:41 am

Re: nrpe nsclient++ check counter - No counters specified

Post by zjllee »

Thanks all!

Turns out I did not initiate the nsclient config file properly. By running nscp settings --generate --add-defaults --load-all in the nsclient install folder, I am able to set allow arguments and allow nasty characters to 1. Did the trick.

Code: Select all

root@nagioscore:/usr/lib/nagios/plugins# ./check_nrpe -H winserver -c CheckCounter -a 'Counter:Idle Timer=\Processor Information(_Total)\% Idle Time' Showall MaxWarn=80 MaxCritcrit=90
WARNING: Idle Timer = 95|'Idle Timernone'=95;80;0

Code: Select all

root@nagioscore:/usr/lib/nagios/plugins# ./check_nrpe -H winserver -c CheckCounter -a "Counter=\\Server\\Errors Logon"
OK: \Server\Errors Logon = 0|'\Server\Errors Logonnone'=0;0;0
With regards to slashes and quotes, single slashes work with single quotes, and double slashes work with double quotes.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: nrpe nsclient++ check counter - No counters specified

Post by rkennedy »

Ah, nice find -- I had ruled out the single quotes.

Are we good to mark this as resolved?
Former Nagios Employee
zjllee
Posts: 3
Joined: Fri Jun 10, 2016 3:41 am

Re: nrpe nsclient++ check counter - No counters specified

Post by zjllee »

lmiltchev wrote:Can you show us the actual command run from the command line along with the output of it?

Example:

Code: Select all

[root@localhost libexec]# ./check_nrpe -H x.x.x.x -c CheckCounter -a 'Counter:Idle Timer=\Processor Information(_Total)\% Idle Time' Showall MaxWarn=80 MaxCritcrit=90
WARNING: Idle Timer = 94|'Idle Timernone'=94;80;0
Also, show us the "check_nrpe" command definition.
Just add on, my command was defined wrongly - this was the main cause of the error as checkcounter requires the -a attribute to be defined.

Wrong

Code: Select all

define command{
        command_name    check_nrpe
        command_line    /usr/lib/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c '$ARG1$'
}
Correct

Code: Select all

define command {
        command_name    check_nrpe
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
This issue can be considered resolved. Thanks to all for the advice.
Locked