[Pkg-nagios-devel] Suggested patch for timeperiod daterange problem

Mike Bird mgb-debian at yosemite.net
Sat May 31 23:05:45 UTC 2008

Since we started using "day 1 - -1" in timeperiod objects a
few months back we've experienced problems on the last day of
each month with checks and notifications not occurring.

The problem seems to be in base/utils.c:

--- base/utils.c.original	2008-03-10 13:58:33.000000000 -0700
+++ base/utils.c	2008-05-31 15:45:09.000000000 -0700
@@ -1523,7 +1523,7 @@
 		/* make the new time */
-		t.tm_mday+=(monthday<-30)?-30:monthday;
+		t.tm_mday+=(monthday<-30)?-30:monthday+1;
 		/* if we rolled over to the previous month, time is invalid */

On entry into the above code, t.tm_mday is the last day of the month.
Adding a monthday of -1 changes t.tm_mday to the day before the last
day of the month, but -1 is supposed to mean the last day of the month.
Therefore we have to add +1 to compensate.

(The above patch is against version 3.0.1 via Debian.)

--Mike Bird

More information about the Pkg-nagios-devel mailing list