<br><tt><font size=2>Hi Bernd,</font></tt>
<br><tt><font size=2>hi Andreas,<br>
</font></tt>
<br><tt><font size=2>> To alleviate your issue, you should be running
an ntp daemon<br>
> on the Nagios server which slews the clock into its right<br>
> time rather than sets it (slew = make it go slightly faster<br>
> or slower until it matches the correct time). Are you running<br>
> ntpdate via a cronjob or something?<br>
></font></tt>
<br><tt><font size=2>> I'm not sure how one would go about debugging
this, as the<br>
> time required to run a single test is prohibitive for rapid<br>
> repeated testing.<br>
</font></tt>
<br><tt><font size=2>I already encountered that problem before and started
debugging it,</font></tt>
<br><tt><font size=2>so I'll just share my knowledge so far. Sadly I didn't
get the time</font></tt>
<br><tt><font size=2>yet to really pinpoint a solution to it and produce
a patch.</font></tt>
<br><tt><font size=2>I'm not that big fan of C ;)</font></tt>
<br>
<br><tt><font size=2>How to produce it:</font></tt>
<br>
<br><tt><font size=2>- define a check "freaky_check" with limited
check_period, let's</font></tt>
<br><tt><font size=2>  call it 7to11 and a check_interval of 3</font></tt>
<br><tt><font size=2>- produce steady time-shifts backwards (nagios running
in a VM someone?)</font></tt>
<br>
<br><tt><font size=2>What happens:</font></tt>
<br>
<br><tt><font size=2>1. it's 11pm, nagios schedules freaky_check for 7am
according to its check_period</font></tt>
<br><tt><font size=2>2. Every X minutes timeshift -1 sec (jittering timesource)</font></tt>
<br><tt><font size=2>3. nagios tries to compensate it and adjusts _all_
checks to the timeshift (next_check = next_check - timeshift)</font></tt>
<br><tt><font size=2>4. time goes by from 11pm to 6am, shifting time for
- let's say - 8 minutes back</font></tt>
<br><tt><font size=2>5. freaky_check is now scheduled for 6:52am because
of the timeshifts</font></tt>
<br><tt><font size=2>6. it's 6:52am and nagios tries to run the freaky_check
according to the schedule</font></tt>
<br><tt><font size=2>7. sanity check says: ERROR: check outside check_period</font></tt>
<br><tt><font size=2>8. nagios tries to compensate with a strange logic:
next_check = next_check + check_interval and just hopes it will fit</font></tt>
<br><tt><font size=2>9. nagios reruns the sanity check: FATAL ERROR: check
still outside check_period - I have no clue what to do: rescheduling freaky_check:
next_check = next_check + 1year</font></tt>
<br><tt><font size=2>10. user puzzled and nagios thinks it's all cool</font></tt>
<br>
<br><tt><font size=2>Conclusion:</font></tt>
<br>
<br><tt><font size=2>This behaviour turns up when the following criterias
are met:</font></tt>
<br>
<br><tt><font size=2>- check has a reduced check_period</font></tt>
<br><tt><font size=2>- time is shifting back</font></tt>
<br><tt><font size=2>- the timeshift outside the check_period is greater
then 2 times the</font></tt>
<br><tt><font size=2>  check_interval</font></tt>
<br>
<br><tt><font size=2>You can look it up in base/checks.c within the</font></tt>
<br><tt><font size=2>run_scheduled_service_check(service *svc, int check_options,
double latency)</font></tt>
<br><tt><font size=2>function for example. </font></tt>
<br>
<br><tt><font size=2>After some basic checks this will be run:</font></tt>
<br>
<br><tt><font size=2>/* attempt to run the check */</font></tt>
<br><tt><font size=2>result=run_async_service_check(svc,check_options,latency,TRUE,TRUE,&time_is_valid,&preferred_time);</font></tt>
<br>
<br><tt><font size=2>which in turn ends up with:</font></tt>
<br>
<br><tt><font size=2>/* is the service check viable at this time? */</font></tt>
<br><tt><font size=2>if(check_service_check_viability(svc,check_options,time_is_valid,preferred_time)==ERROR)</font></tt>
<br><tt><font size=2>   return ERROR;</font></tt>
<br>
<br><tt><font size=2>No, since nagios shifted it outside its check_period,
the time is NOT valid.</font></tt>
<br>
<br><tt><font size=2>Back in run_scheduled_service_check we now enter the
(if result==ERROR) tree:</font></tt>
<br>
<br><tt><font size=2>/* get current time */</font></tt>
<br><tt><font size=2>time(&current_time);</font></tt>
<br>
<br><tt><font size=2>/* determine next time we should check the service
if needed */</font></tt>
<br><tt><font size=2>/* if service has no check interval, schedule it again
for 5 minutes from now */</font></tt>
<br><tt><font size=2>if(current_time>=preferred_time)</font></tt>
<br><tt><font size=2>   preferred_time=current_time+((svc->check_interval<=0)?300:(svc->check_interval*interval_length));</font></tt>
<br>
<br><tt><font size=2>COMMENT: nagios added the check_interval to preferred_time</font></tt>
<br>
<br><tt><font size=2>/* make sure we rescheduled the next service check
at a valid time */</font></tt>
<br><tt><font size=2>get_next_valid_time(preferred_time,&next_valid_time,svc->check_period_ptr);</font></tt>
<br>
<br><tt><font size=2>COMMENT: No, it didn't do as adding check_interval
was not enough to compensate the backshift in time</font></tt>
<br>
<br><tt><font size=2>/* the service could not be rescheduled properly -
set the next check time for next year, but don't</font></tt>
<br><tt><font size=2> actually reschedule it */</font></tt>
<br><tt><font size=2>if(time_is_valid==FALSE && next_valid_time==preferred_time){</font></tt>
<br>
<br><tt><font size=2>COMMENT: nagios it bailing out here and just adding
1 year to preferred_time to get the scheduler running again</font></tt>
<br>
<br><tt><font size=2>svc->next_check=(time_t)(next_valid_time+(60*60*24*365));</font></tt>
<br><tt><font size=2>svc->should_be_scheduled=FALSE;</font></tt>
<br>
<br><tt><font size=2>log_debug_info(DEBUGL_CHECKS,1,"Unable to find
any valid times to reschedule the next service check!\n");</font></tt>
<br><tt><font size=2>               
                }</font></tt>
<br>
<br><tt><font size=2>/* this service could be rescheduled... */</font></tt>
<br><tt><font size=2>  else{</font></tt>
<br><tt><font size=2>        svc->next_check=next_valid_time;</font></tt>
<br><tt><font size=2>        svc->should_be_scheduled=TRUE;</font></tt>
<br>
<br><tt><font size=2>        log_debug_info(DEBUGL_CHECKS,1,"Rescheduled
next service check for %s",ctime(&next_valid_time));</font></tt>
<br><tt><font size=2>      }</font></tt>
<br><tt><font size=2>}</font></tt>
<br>
<br><tt><font size=2>COMMENT: BÄNG - our check just got shoved to mars
- landing in 1 year and we don't even get</font></tt>
<br><tt><font size=2>a notification for it and it does not orphan or whatever...</font></tt>
<br>
<br>
<br><tt><font size=2>The question is now - what's the smartest way to handle
this?</font></tt>
<br><tt><font size=2>Basically I see 2 different approaches:</font></tt>
<br>
<br><tt><font size=2>1. When compensating timeshifts - doublecheck that
you do not move a check outside its valid check_period</font></tt>
<br><tt><font size=2>2. When trying to schedule checks, that somehow ran
outside its check_period - try to be smart and look for</font></tt>
<br><tt><font size=2>the next valid time inside the check_period of that
check instead of just adding check_interval and naivly</font></tt>
<br><tt><font size=2>hoping for it to be allright</font></tt>
<br>
<br><tt><font size=2>Ok, so far from me - /discuss :-)</font></tt>
<br>
<br><tt><font size=2>S</font></tt>
<br>
<br><font size=2 face="sans-serif">-- <br>
Sascha Runschke<br>
IT-Infrastruktur<br>
<br>
GFKL Financial Services AG<br>
Limbecker Platz 1<br>
45127 Essen<br>
<br>
Telefon : +49 (201) 102-1879 Mobil : +49 (173) 5419665 Fax : +49 (201)
102-1102105</font>
<br>
<br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">GFKL Financial Services AG</span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">Vorstand: Dr. Peter Jänsch (Vors.), Jürgen Baltes, Dr. Till Ergenzinger, Dr. Tom Haverkamp</span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">Vorsitzender des Aufsichtsrats: Dr. Georg F. Thoma</span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">Sitz: Limbecker Platz 1, 45127 Essen, Amtsgericht Essen, HRB 13522</span>