Not able to pass brackets [] within a service check

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
DonB
Posts: 39
Joined: Mon Mar 11, 2013 3:26 pm

Not able to pass brackets [] within a service check

Post 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
Last edited by DonB on Wed Nov 20, 2013 3:09 pm, edited 3 times in total.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

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

Post 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.
DonB
Posts: 39
Joined: Mon Mar 11, 2013 3:26 pm

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

Post 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
	}
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
DonB
Posts: 39
Joined: Mon Mar 11, 2013 3:26 pm

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

Post by DonB »

Yes, I am getting the performance data for both input & output.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
DonB
Posts: 39
Joined: Mon Mar 11, 2013 3:26 pm

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

Post 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!!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked