Xymon Mailing List Archive search

COLOR keyword in alerts

8 messages in this thread

list Bruce Lysik · Thu, 3 Feb 2005 11:14:49 -0800 ·
Hi,

Can COLOR take two arguments?  ie, COLOR=red,purple

--
Bruce Z. Lysik  <user-4e63a10f8934@xymon.invalid>
Operations Engineer
list Henrik Størner · Thu, 3 Feb 2005 22:00:55 +0100 ·
On Thu, Feb 03, 2005 at 11:14:49AM -0800, Bruce Lysik wrote:
Hi,

Can COLOR take two arguments?  ie, COLOR=red,purple

Yes.


Henrik
list Bruce Lysik · Fri, 4 Feb 2005 10:51:08 -0800 ·
Can COLOR take two arguments?  ie, COLOR=red,purple

Yes.
Hmm.  I added COLOR=red,purple to every recipient line, but it doesn't show up in dump-config.

--
Bruce Z. Lysik  <user-4e63a10f8934@xymon.invalid>
Operations Engineer
list Henrik Størner · Fri, 4 Feb 2005 22:28:59 +0000 (UTC) ·
quoted from Bruce Lysik
In <user-edaa5a1f9b02@xymon.invalid> "Bruce Lysik" <user-4e63a10f8934@xymon.invalid> writes:

Can COLOR take two arguments?  ie, COLOR=red,purple
Yes.
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 ?


Henrik
list Bruce Lysik · Fri, 4 Feb 2005 14:50:55 -0800 ·
quoted from Henrik Størner
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 ?
Here's the bit from hobbit-alert.cfg:

HOST=$HG-IA
#       SCRIPT /opt/bb/server/ext/email onduty SERVICE=3dm,procs RECOVERED COLOR=red,purple
#       SCRIPT /opt/bb/server/ext/email ops    SERVICE=3dm,procs RECOVERED COLOR=red,purple
#       SCRIPT /opt/bb/server/ext/email onduty SERVICE=conn DURATION>6 RECOVERED COLOR=red,purple
#       SCRIPT /opt/bb/server/ext/email ops    SERVICE=conn DURATION>6 RECOVERED COLOR=red,purple
#       SCRIPT /opt/bb/server/ext/email ops    EXSERVICE=3dm,procs,conn RECOVERED COLOR=red,purple
        SCRIPT /opt/bb/server/ext/email bruce_mail FORMAT=text RECOVERED COLOR=red,purple DURATION>6

Here's the config-dump:

HOST=<snip lots of hosts>
	SCRIPT /opt/bb/server/ext/email bruce_mail FORMAT=SCRIPT REPEAT=30 DURATION>6 RECOVERED 

--
Bruce Z. Lysik  <user-4e63a10f8934@xymon.invalid>
Operations Engineer
list Henrik Størner · Sat, 5 Feb 2005 09:06:05 +0100 ·
quoted from Bruce Lysik
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");
list Bruce Lysik · Mon, 7 Feb 2005 11:04:15 -0800 ·
quoted from Henrik Størner
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/
Great.  Looks like the patch does the trick.

Question:  If I have COLOR=red,purple and RECOVERED, will I get recovery alerts for machines which go into 'yellow'?  Obviously this isn't desired behavior.

Thanks.

--
Bruce Z. Lysik  <user-4e63a10f8934@xymon.invalid>
Operations Engineer
list Henrik Størner · Mon, 7 Feb 2005 21:47:11 +0100 ·
quoted from Bruce Lysik
On Mon, Feb 07, 2005 at 11:04:15AM -0800, Bruce Lysik wrote:
Question: If I have COLOR=red,purple and RECOVERED, will I get
 recovery alerts for machines which go into 'yellow'?  Obviously this
 isn't desired behavior.
This was raised a while ago, and ended up with two options for
hobbitd: The --alertcolors option defines which colors are critical
and may result in an alert, and the --okcolors option that defines
which colors may result in a recovery message.

By default, red yellow and purple are considered critical, and
green blue and clear are OK. So with the scenario you describe, you
will NOT get a recovery message when the status goes yellow - only
when it goes green. However, no alerts will be sent while the status
is yellow.


Henrik