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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

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

Post by Guest »

This is a multi-part message in MIME format.
--------------070808020603040407020108
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 08/24/2010 11:30 PM, Jochen Bern wrote:
> 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.

Update:
-- Improved Command Expansion
-- Non-$ARGn$ macros and $$'s are now color coded, too
-- Better coverage of error cases
-- Reused expand=3D parameter to add functionality to other display_*()s'
output (mostly "list only object with that name", but services and
service dependencies match *host* names, for decently-sized lists)
-- Changed a bunch of hyperlinks so as to use that functionality

(From a debugging perspective, the best approach would IMHO be to have
expand-to-execute and expand-to-inspect done by the *exact same* macro
handling functions. However, the preexisting macro expanders don't have
a debug mode, and config.cgi would need to do a *lot* of majick to get a
reasonable list of $HOST*$ and $SERVICE*$ macros' values for a full
expansion, so that's rather unlikely to happen ...)

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

--------------070808020603040407020108
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-25 13:21:51.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,10 @@
authdata current_authdata;

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

int embedded=FALSE;

@@ -217,6 +223,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 +276,9 @@
case DISPLAY_HOSTESCALATIONS:
display_hostescalations();
break;
+ case DISPLAY_COMMAND_EXPANSION:
+ display_command_expansion();
+ break;
default:
display_options();
break;
@@ -340,6 +353,7 @@
int x;

variables=getcgivars();
+ to_expand[0]='\0';

for(x=0;variables[x]!=NULL;x++){

@@ -382,12 +396,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 string-to-expand argument */
+ else if(!strcmp(variables[x],"expand")){
+ x++;
+ if(variables[x]==NULL){
+ error=TRUE;
+ break;
+ }
+ strncpy(to_expand,variables[x],MAX_COMMAND_BUFFER);
+ to_expand[MAX_COMMAND_BUFFER-1]='\0';
+ }
+
+
/* we received an invalid argument */
else
error=TRUE;
@@ -420,7 +448,8 @@
return;
}

- printf("Hosts</

...[email truncated]...


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