Bug and (loosely related) patch: Nagios 3.2.1 config.cgi, commands with $ARGs$

Jochen Bern Jochen.Bern at LINworks.de
Tue Aug 24 23:30:24 CEST 2010


Bug noticed while working on the attached patch: If you use a command
anywhere *other* than as a service's check_command that has "!" and
$ARGs$ (e.g., define a host with

	check_command		check-host-alive!foo!bar!baz

), when showing the config in question, config.cgi fails to strip the
suffix before passing the command into url_encode(). The net result is
that the page displaying the command makes it into a hyperlink to, e.g.,

	config.cgi?type=commands#check-host-alive%21foo%21bar%21baz

while the actual list of commands only provides an anchor like

	<A NAME='check-host-alive'></A>check-host-alive

so clicking the link fails to scroll to the proper line.

-------

Having that said, and after seeing too many people unable to do $ARGn$
substitution correctly in their head or with pen and paper, I wrote a
patch for config.c which makes the links display the appropriate
"expansion" right away. I.e., if your config reads

define command{
	command_name	check-host-alive
	command_line	$USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$
				-c $ARG2$ -n $ARG3$
}
define host{
	host_name	TestBox
	check_command	check-host-alive!3000.0,80%!5000.0,100%
}

and you click the link "check-host-alive!3000.0,80%!5000.0,100%" in
TestBox's line in the list of host configurations, rather than jumping
into the middle of an unannotated list of commands, you get a page saying:

To expand:		check-host-alive!3000.0,80%!5000.0,100%
check-host-alive	$USER1$/check_icmp -H $HOSTADDRESS$ -w $ARG1$
			-c $ARG2$ -n $ARG3$
		->	$USER1$/check_icmp -H $HOSTADDRESS$ -w
			3000.0,80% -c 5000.0,100% -n (undefined/empty)

complete with <FONT COLOR=>-based visual aids.

Kind regards,
								J. Bern
-- 
Jochen Bern, Systemingenieur --- LINworks GmbH <http://www.LINworks.de/>
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP = D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C27
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Geschäftsführer Metin Dogan, Oliver Michel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nagios-3.2.1-CommandExpand-patch.txt
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20100824/24526069/attachment.txt>
-------------- next part --------------
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list