Page 1 of 1

Problem reading perfmon counter from within Nagios XI

Posted: Mon May 27, 2013 9:47 am
by DennisPR
I want to create a service showing me the number of Terminal Server connections by reading a perfmon counter with check_nt & nsclient 0.3.9
The test works fine from the command line as followed :

Code: Select all

/usr/local/nagios/libexec/check_nt -H 10.75.105.10 -s "N4gi0s" -p 12489 -v COUNTER -l "\\Terminal Services\\Total Sessions","TS  Connections are %.f"  -w 10 -c 20  
TS  Connections are 7 | 'TS  Connections are %.f'=7.000000%;10.000000;20.000000;

So I created a service as followed :

Code: Select all

define service {
	host_name			servername
	service_description		MS RDP : Current Connections
	use				service-template
	check_command			check_xi_service_nsclient!password!COUNTER -l "\Terminal Services\Total Sessions","TS  Connections are %.f"  -w 10 -c 20!!!!!!
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			xi_timeperiod_24x7
	notification_period		xi_timeperiod_24x7
	contacts			nagiosadmin
	_xiwizard			windowsserver
	register			1
	}	
If I test the service with "test check command" button in CCM it works fine

Code: Select all

COMMAND: /usr/local/nagios/libexec/check_nt -H 10.75.105.10 -s "N4gi0s" -p 12489 -v COUNTER -l "\\Terminal Services\\Total Sessions","TS  Connections are %.f"  -w 10 -c 20  
OUTPUT: TS  Connections are 7 | 'TS  Connections are %.f'=7.000000%;10.000000;20.000000;

So far so good... however. If I run the service through Nagios XI I get Performance Data: 'TS Connections are %.f'=0.000000%;10.000000;20.000000; as result in stead of 7 and I get the following error in the nsclient.log

Code: Select all

2013-05-27 16:39:10: error:modules\CheckSystem\CheckSystem.cpp:1084: ERROR: Counter not found: Terminal ServicesTotal Sessions: Unable to parse the counter path. Check the format and syntax of the  specified path.   (C0000BC0)
2013-05-27 16:39:10: error:modules\CheckSystem\CheckSystem.cpp:1086: ERROR: Counter not found: Terminal ServicesTotal Sessions: Unable to parse the counter path. Check the format and syntax of the  specified path.   (C0000BC0)
2013-05-27 16:39:10: error:modules\CheckSystem\CheckSystem.cpp:1115: ERROR: Terminal ServicesTotal Sessions: PdhAddCounter failed: Unable to parse the counter path. Check the format and syntax of the  specified path.   (C0000BC0) (Terminal ServicesTotal Sessions|Terminal ServicesTotal Sessions)
I think the problem is caused by the \ in the arguments. I've used single \ in $ARG2$ but Nagios XI/CCM uses double \ when testing the command and writes single \ in the service definition.

Extra info : I am using NSClient++-0.3.9-x64 from http://nsclient.org/nscp/downloads
Can someone tell me what's wrong please.
I have the same problem reading other perfmon counters as well.

Re: Problem reading perfmon counter from within Nagios XI

Posted: Tue May 28, 2013 10:35 am
by slansing
You will need to add double "\\" to the command definition due to escaping rules, the reason is, the way paths are defined with performance counters, "using \'s" this actually is an escape character within Nagios, so you need to double them in your command definition since Nagios will remove one. This will cause the Test Check Command to not function as it will automatically double slashes, so it will end up trying to use "\\\\" however you will still be able to get valid check results through the main interface, Service Details page, etc. Let us know how things look after you make the change.

Re: Problem reading perfmon counter from within Nagios XI

Posted: Wed May 29, 2013 11:03 am
by DennisPR
Thx for the info, works perfect !