Page 1 of 1

[Nagios-devel] Bug and (loosely related) patch: Nagios 3.2.1

Posted: Tue Aug 24, 2010 8:30 pm
by Guest
This is a multi-part message in MIME format.
--------------090802060403060509020804
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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=3Dcommands#check-host-alive%21foo%21bar%21baz

while the actual list of commands only provides an anchor like

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 -based visual aids.

Kind regards,
J. Bern
--=20
Jochen Bern, Systemingenieur --- LINworks GmbH
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP =3D D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C2=
7
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Gesch=E4ftsf=FChrer Metin Dogan, Oliver Mic=
hel

--------------090802060403060509020804
Content-Type: text/plain;
name="nagios-3.2.1-CommandExpand-patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="nagios-3.2.1-CommandExpand-patch.txt"

--- config.c.orig 2009-05-15 16:02:47.000000000 +0200
+++ config.c 2010-08-24 22:34:47.000000000 +0200
@@ -65,6 +65,7 @@
#define DISPLAY_HOSTDEPENDENCIES 11
#define DISPLAY_HOSTESCALATIONS 12
#define DISPLAY_SERVICEGROUPS 15
+#define DISPLAY_COMMAND_EXPANSION 16211

void document_header(int);
void document_footer(void);
@@ -84,6 +85,7 @@
void display_serviceescalations(void);
void display_hostdependencies(void);
void display_hostescalations(void);
+void display_command_expansion(void);

void unauthorized_message(void);

@@ -91,6 +93,9 @@
authdata current_authdata;

int display_type=DISPLAY_NONE;
+char full_command[MAX_COMMAND_BUFFER];
+char *command_args[MAX_COMMAND_ARGUMENTS];
+char hashed_color[8];

int embedded=FALSE;

@@ -217,6 +222,10 @@
case DISPLAY_HOSTESCALATIONS:
display_context_help(CONTEXTHELP_CONFIG_HOSTESCALATIONS);
break;
+ case DISPLAY_COMMAND_EXPANSION:
+ /* Reusing DISPLAY_COMMANDS help until further notice */
+ display_context_help(CONTEXTHELP_CONFIG_COMMANDS);
+ break;
default:
display_context_help(CONTEXTHELP_CONFIG_MENU);
break;
@@ -266,6 +275,9 @@
case DISPLAY_HOSTESCALATIONS:
display_hostescalations();
break;
+ case DISPLAY_COMMAND_EXPANSION:
+ display_command_expansion();
+ break;
default:
display_options();
break;
@@ -382,12 +394,26 @@
display_type=DISPLAY_HOSTDEPENDENCIES;
else if(!strcmp(variables[x],"hostescalations"))
display_type=DISPLAY_HOSTESCALATIONS;
+ else if(!strcmp(variables[x],"command"))
+ display_type=DISPLAY_COMMAND_EXPANSION;

/* we found the embed option */
else if(!strcmp(variables[x],"embedded"))
embedded=TRUE;
}

+ /* we found the comm

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]