Page 1 of 1

Not able to pass brackets [] within a service check

Posted: Wed Nov 20, 2013 3:00 pm
by DonB
I have a check command that I can get to work at the command line and from the service using "Test Check Command", but when it is runs normally. It appears since I have to pass brackets as part of the network interface name, some where the command format is being modified, maybe...

I first start coping a large file to create network traffic.

From the command line, note that I have output for bytes_in and bytes_out and notice the [R] is part the interface name.

Code: Select all

# ./check_win_net_usage.sh -H test1 -i "Intel[R] PRO_1000 MT Network Connection" -o MB
Network OK - 0 MBytes received/sec, 0 MBytes sent/sec|bytes_in=342;bytes_out=60
When I run the "Test Check Command" from the service, I have to modify the Interface name by adding quotes around the name and additional quotes around [R]. I also see that the test automatically adds backslashes to the command. This will work. I can see network traffic.
If I don't have the syntax correct, I do not receive an error, instead I just get the input and output is zero.

Command Config

Code: Select all

define command {
       command_name check_net_traffic_win
       command_line $USER1$/check_win_net_usage.sh -H $HOSTADDRESS$ -i $ARG1$ -o $ARG2$ 
}
Service Config, note I do not add backslashes around "[R]"

Code: Select all

define service {
	host_name                test1
	service_description	Network_Traffic
	use				st_check_60_auto_ack__24x7
	check_command	check_net_traffic_win!"Intel"[R]" PRO_1000 MT Network Connection"!MB!!!!!!
	register			1
	}	
Test output for "Test Check Command" button, note the test inserts backslashes automatically: "\[R\]"

Code: Select all

Testing check from command line...

COMMAND: /usr/local/nagios/libexec/check_win_net_usage.sh -H test1 -i "Intel"\[R\]" PRO_1000 MT Network Connection" -o MB 
OUTPUT: Network OK - 0 MBytes received/sec, 0 MBytes sent/sec|bytes_in=406;bytes_out=60
But when I run the "Immediate test" from the active service, the service output shows no traffic, 0 MBytes. I'm not certain how to see the command output from NagiosXI at this point.

Code: Select all

Network OK - 0 MBytes received/sec, 0 MBytes sent/sec
Thank you for helping!
Don

Re: Not able to pass brackets [] within a service check

Posted: Wed Nov 20, 2013 3:03 pm
by slansing
In the CCM You will likely need to change $ARG2$ to:

Code: Select all

"Intel"\[R\]" PRO_1000 MT Network Connection"
Or:

Code: Select all

"Intel"\\[R\\]" PRO_1000 MT Network Connection"
However you will have to test this by using the Home > Services > "Servicename" page, as the Test Check Command feature does not play nice with slashes.

Re: Not able to pass brackets [] within a service check

Posted: Wed Nov 20, 2013 3:23 pm
by DonB
Thank you for the quick response!

I tried the two configurations settings on $ARG1$ and kept $ARG2$ = MB. But still received zero in/outputs.

Code: Select all

define service {
	host_name			test1
	service_description		Network_Traffic
	use				        st_check_60_auto_ack__24x7
	check_command	        check_net_traffic_win!"Intel"\[R\]" PRO_1000 MT Network Connection"!MB!!!!!!
	register			        1
	}	

And:

Code: Select all

define service {
	host_name			test1
	service_description		Network_Traffic
	use				        st_check_60_auto_ack__24x7
	check_command		check_net_traffic_win!"Intel"\\[R\\]" PRO_1000 MT Network Connection"!MB!!!!!!
	register			        1
	}	
Also tried some additional options, but still didn't work.

Code: Select all

define service {
	host_name			test1
	service_description		Network_Traffic
	use				st_check_60_auto_ack__24x7
	check_command			check_net_traffic_win!"Intel"\["R"\]" PRO_1000 MT Network Connection"!MB!!!!!!
	register			1
	}	

Code: Select all

define service {
	host_name			test1
	service_description		Network_Traffic
	use				st_check_60_auto_ack__24x7
	check_command			check_net_traffic_win!"Intel"\\["R"\\]" PRO_1000 MT Network Connection"!MB!!!!!!
	register			1
	}

Re: Not able to pass brackets [] within a service check

Posted: Wed Nov 20, 2013 5:59 pm
by abrist
Can you check the performance data for the check in the service details in xi? Are both in/out zero there as well?

Re: Not able to pass brackets [] within a service check

Posted: Thu Nov 21, 2013 9:13 am
by DonB
Yes, I am getting the performance data for both input & output.

Re: Not able to pass brackets [] within a service check

Posted: Thu Nov 21, 2013 12:11 pm
by abrist
If the perf data is more than 0, then it is the status output that is getting rounded down and the plugin is working correctly.

Re: Not able to pass brackets [] within a service check

Posted: Thu Nov 21, 2013 4:54 pm
by DonB
Ok, I see what your saying, the output in MB is so low, it rounds it to zero. I notice that now from the command line tests I posted earlier. The numbers I'm seeing are used by the performance graph "only".... Thank you very much!!

Re: Not able to pass brackets [] within a service check

Posted: Thu Nov 21, 2013 4:59 pm
by lmiltchev
Great! I am locking this topic and marking it as "resolved". If you have any more (unrelated) questions, please, start a new thread.