Time Conversion Bug (Was: no email notifications sent)

Ton Voon ton.voon at opsera.com
Tue Nov 3 14:09:25 CET 2009


Hi Albrecht,

On 3 Dec 2008, at 20:01, Albrecht Dreß wrote:

> Am 01.12.08 21:59 schrieb(en) Albrecht Dreß:
>> I have a self-compiled nagios 3.0.5 running on a 64-bit Xeon box  
>> with Ubuntu 8.04 LTS.  Everything went perfectly (including  
>> notifications) until I upgraded from 3.0.1 (iirc) to 3.0.5 during a  
>> bigger service downtime (inter alia shifting the box into an other  
>> network etc).
>
> After adding tons of debug messages, I was finally able to track  
> down the problem.  The problem is that I added a german holiday in  
> the form
>
>        october 3       00:00-00:00
>
> In function (all inbase/utils.c) check_time_against_period(), the  
> start time was calculated by calculate_time_from_day_of_month() as  
> 1222988400 (Fri Oct  3 01:00:00 2008), but the end time as  
> 1222984800 (Fri Oct  3 00:00:00 2008), which is /before/ the start,  
> and therefore the time span was expanded to a whole year, i.e. the  
> end now was Oct 3, 2009...
>
> Looking deeper into function calculate_time_from_day_of_month(),  
> this is apparently caused by a wrong usage of the call to mktime(),  
> as the field tm_isdst is /not/ initialised properly.  The observed 1  
> hour offset seems to come from an earlier call to this function  
> which returned an active dst flag.
>
> According to the IEEE Std 1003.1 [1], the field tm_isdst /is/ used  
> in the time conversion, and should be set to -1 if the dst status is  
> unknown (you may want to write a small test app, setting this flag  
> to -1, 0 or 1 to observe the effect).  As mktime() is used  
> frequently in the code without properly initialising this field,  
> this seems to be a systematic bug which can trigger interesting  
> effects in nagios.
>
> Any opinions?

As you are probably aware, this change has caused the DST bug that has  
affected a lot of users of Nagios 3.2.0.

I have only reverted one instance of the tm_isdst field, which was  
specifically causing the rescheduling problem. There is a testcase in  
HEAD ( download from http://nagios.sourceforge.net/download/cvs/nagios-HEAD.tar.gz 
  && ./configure --enable-libtap && make all && make test) which tests  
the DST bug (see t-tap/check_timeperiods.c).

However, I think some of the other isdst settings maybe causing other  
bugs, though I'm not sure.

It would be helpful if you could add some test for the problem you  
have fixed, to prove that the functionality you expect continues to  
work. I'd be happy to apply to CVS if you have an updated  
check_timeperiods.c file.

Ton


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list