Xymon Mailing List Archive search

Alert rules

list Henrik Størner
Wed, 29 Jun 2005 22:20:02 +0200
Message-Id: <user-cf8e1ddcd7f0@xymon.invalid>

On Wed, Jun 29, 2005 at 08:55:31PM +0200, Henrik Stoerner wrote:
On Wed, Jun 29, 2005 at 01:27:45PM -0400, Killenbeck, Alan wrote:
I've been asked to try to make alerts only send 2 emals, at most, and
still send a RECOVERED message when things recover.
It's a bug. Will fix.
I think this patch should do it.

--- hobbitd/do_alert.c	2005/06/06 09:27:07	1.69
+++ hobbitd/do_alert.c	2005/06/29 18:58:54
@@ -960,20 +960,26 @@
 	/* At this point, we know the configuration may result in an alert. */
 	if (anymatch) (*anymatch)++;
 -	duration = (time(NULL) - alert->eventstart);
-	if (crit && crit->minduration && (duration < crit->minduration)) { -		traceprintf("Failed '%s' (min. duration %d<%d)\n", cfline, duration, crit->minduration);
-		if (!printmode) return 0; -	}
+	/* +	 * Time checks should be done on real paging messages only. +	 * Not on recovery- or notify-messages.
+	 */
+	if (alert->state == A_PAGING) {
+		duration = (time(NULL) - alert->eventstart);
+		if (crit && crit->minduration && (duration < crit->minduration)) { +			traceprintf("Failed '%s' (min. duration %d<%d)\n", cfline, duration, crit->minduration);
+			if (!printmode) return 0; +		}
 -	if (crit && crit->maxduration && (duration > crit->maxduration)) { -		traceprintf("Failed '%s' (max. duration %d>%d)\n", cfline, duration, crit->maxduration);
-		if (!printmode) return 0; -	}
+		if (crit && crit->maxduration && (duration > crit->maxduration)) { +			traceprintf("Failed '%s' (max. duration %d>%d)\n", cfline, duration, crit->maxduration);
+			if (!printmode) return 0; +		}
 -	if (crit && crit->timespec && !timematch(crit->timespec)) { -		traceprintf("Failed '%s' (time criteria)\n", cfline);
-		if (!printmode) return 0; +		if (crit && crit->timespec && !timematch(crit->timespec)) { +			traceprintf("Failed '%s' (time criteria)\n", cfline);
+			if (!printmode) return 0; +		}
 	}
  	/* Check color. For RECOVERED messages, this holds the color of the alert, not the recovery state */