Time Conversion Bug (Was: no email notifications sent)
Albrecht Dreß
albrecht.dress at arcor.de
Wed Dec 3 21:01:05 CET 2008
Hi all:
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?
Best, Albrecht.
[1]
<http://www.opengroup.org/onlinepubs/009695399/functions/mktime.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20081203/6b84cfaa/attachment.sig>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------- next part --------------
_______________________________________________
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