[hobbit] COLOR keyword in alerts

Henrik Stoerner henrik at hswn.dk
Sat Feb 5 09:06:05 CET 2005


On Fri, Feb 04, 2005 at 02:50:55PM -0800, Bruce Lysik wrote:
> 
> > > Hmm.  I added COLOR=red,purple to every recipient line, but it
> > > doesn't show up in dump-config.
> > 
> > Works for me. Could you post just one of these rules/recipients that
> > doesn't work ?

>         SCRIPT /opt/bb/server/ext/email bruce_mail FORMAT=text RECOVERED COLOR=red,purple DURATION>6

OK, it's a bug that triggers when you have a color-setting followed by
some other rule.

Patch is attached, it is also available at http://www.hswn.dk/beta/


Regards,
Henrik
-------------- next part --------------
--- hobbitd/do_alert.c	2005/02/02 22:07:39	1.31
+++ hobbitd/do_alert.c	2005/02/05 08:01:52
@@ -13,7 +13,7 @@
 /*                                                                            */
 /*----------------------------------------------------------------------------*/
 
-static char rcsid[] = "$Id: do_alert.c,v 1.31 2005/02/02 22:07:39 henrik Exp $";
+static char rcsid[] = "$Id: do_alert.c,v 1.32 2005/02/05 08:01:04 henrik Exp $";
 
 /*
  * The alert API defines three functions that must be implemented:
@@ -122,7 +122,7 @@
 static rule_t *rulehead = NULL;
 static rule_t *ruletail = NULL;
 static int cfid = 0;
-static char cfline[80];
+static char cfline[256];
 static int stoprulefound = 0;
 
 /*
@@ -157,7 +157,7 @@
 			(*currule)->criteria = (criteria_t *)calloc(1, sizeof(criteria_t));
 		crit = (*currule)->criteria;
 		crit->cfid = cfid;
-		crit->cfline = strdup(cfline);
+		if (crit->cfline == NULL) crit->cfline = strdup(cfline);
 		*currcp = NULL;
 		break;
 
@@ -166,8 +166,7 @@
 			(*currcp)->criteria = (criteria_t *)calloc(1, sizeof(criteria_t));
 		crit = (*currcp)->criteria;
 		crit->cfid = cfid;
-		crit->cfline = strdup(cfline);
-		crit->colors = (*currule)->criteria->colors;
+		if (crit->cfline == NULL) crit->cfline = strdup(cfline);
 		break;
 	}
 
@@ -362,10 +361,8 @@
 			continue;
 		}
 
-		if (tracefd) {
-			strncpy(cfline, l, (sizeof(cfline)-1));
-			cfline[sizeof(cfline)-1] = '\0';
-		}
+		strncpy(cfline, l, (sizeof(cfline)-1));
+		cfline[sizeof(cfline)-1] = '\0';
 
 		/* Expand macros inside the line before parsing */
 		p = strtok(preprocess(l), " \t");


More information about the Xymon mailing list