Xymon Mailing List Archive search

tasks.cfg - strange CRONDATE behaviour

list Jeremy Laidman
Tue, 3 Jun 2014 16:34:05 +1000
Message-Id: <CAAnki7CmbdWq6yhXbv1Pj0c2h5QifLSLhvnmsZF9nyf=user-0c35ecd13b3a@xymon.invalid>

On Tuesday, 3 June 2014, Jeremy Laidman <user-71895fb2e44c@xymon.invalid> wrote:
Yep, when it drifted to 2 seconds after the minute mark I started seeing
my script run twice.  When 3 seconds after the minute, it only runs once.
 Although on one occasion when at 2 seconds past the minute, it only ran
once.
Looks like a logic bug.  The code (xymonlaunch.c) runs a loop for all
tasks, with a 5 second sleep between each run, giving up to 12 loop cycles
per minute.  For CRONDATE entries, it refuses to run a task if the last
time the task was run was within 55 seconds of the current time.  That
opens up the possibility for a job to run at 1 second past the minute and
again at 57 minutes past the minute (or 58 or 59).  If the xymonlaunch loop
takes more than a 3/12 of a second, then at the end of 12 loop cycles, it
will be into the next minute.  But if it takes a little more time, it would
go back into that danger zone (57, 58 or 59 seconds) after only 11 cycles.

Seems to me that a better way would be, instead of seeing if the last run
timestamp was at least 55 seconds before now, check if the last run
timestamp "minute" was the same as now.  This could be easily implemented,
I would think, by seeing if int(laststart / 60) is equal to int(now/60).

J