[RFC] - strange issue on notification filter aka time is not like time?

Hendrik Baecker andurin at process-zero.de
Tue May 12 15:06:25 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Hi list,

I've just ran into a interesting problem with my nagios 3.1.0 code.

Intro:
Take a host with two differenct contactgroups assigned.
One of those cg should notify during daylight (tp-definition:
0800-1700 for example)
and the other contactgroup with one contact member for only non
daylight notifications (tp: 1700-2400,0000-0800).

Nagios is sending out a notification to all possible contacts,
ignoring the notification_period of the contact.

I've already double checked the configs (regarding objects.cache as a
result of all possible template resolutions).
Possible needed config snipplet at the bottom of this message.

Enabled debugging:
# nagios.debug - debug level '-1', debug verobosity '2':
[1242118526.292017] [001.0] [pid=1052] notify_contact_of_host()
[1242118526.292025] [032.2] [pid=1052] ** Attempting to notifying
contact 'bereitschaftshandy1'...
[1242118526.292034] [001.0] [pid=1052]
check_contact_host_notification_viability()
[1242118526.292043] [032.2] [pid=1052] ** Checking host notification
viability for contact 'bereitschaftshandy1'...
[1242118526.292052] [001.0] [pid=1052] check_time_against_period()
[1242118526.292108] [032.2] [pid=1052] ** Host notification viability
for contact 'bereitschaftshandy1' PASSED.
[1242118526.292118] [032.2] [pid=1052] ** Notifying contact
'bereitschaftshandy1'

So the contact host notification filter ends up in PASSED state. (Btw.
Same behavior on service checks)

And now it's getting funny.

In base/notifications.c beginning at line 1414 (latest cvs code) we found:
- -------------------------------
if(check_time_against_period(time(NULL),cntct->service_notification_period_ptr)==ERROR){
...
...
- -------------------------------

time(NULL) should and possibly will return seconds since epoch, so far
so good.

But if I change the check_time_against_period() call to this:

- -------------------------------
time_t current_time;
time(&current_time);
if(check_time_against_period(current_time,cntct->host_notification_period_ptr)==ERROR){
...
...
- -------------------------------

The notification periods works as expected and my
'bereitschaftshandy1' contact won't get a daylight notification.

Can someone please tell me, that it shouldn't matter what I've changed?

Regards
Hendrik

- ----------------------
define contact {
        contact_name    bereitschaftshandy1
        alias   Alias
        service_notification_period     do-non-workhours
        host_notification_period        do-non-workhours
        service_notification_options    c
        host_notification_options       d,u
        service_notification_commands   notify-by-voice,notify-by-sms2mail
        host_notification_commands     
host-notify-by-voice,notify-by-sms2mail
        email   xxxxx
        pager   yxyxyxyxyxyx
        host_notifications_enabled      1
        service_notifications_enabled   1
        can_submit_commands     0
        retain_status_information       0
        retain_nonstatus_information    0
        }

define timeperiod {
        timeperiod_name do-non-workhours
        alias   Non Work Hours
        december 31     12:00-24:00
        december 25 - december 26       00:00-24:00
        december 24     12:00-24:00
        november 1      00:00-24:00
        october 3       00:00-24:00
        may 1   00:00-24:00
        january 1       00:00-24:00
        sunday  00:00-24:00
        monday  00:00-07:00,17:00-24:00
        tuesday 00:00-07:00,17:00-24:00
        wednesday       00:00-07:00,17:00-24:00
        thursday        00:00-07:00,17:00-24:00
        friday  00:00-07:00,17:00-24:00
        saturday        00:00-24:00
        }
- ----------------------

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
 
iD8DBQFKCXRRlI0PwfxLQjkRAqQTAJ4pauzH9s8xpV6vF383sAImMQL6PwCfb7qx
MXS0ZJnRniN1cxs0NV+v3ug=
=S6fK
-----END PGP SIGNATURE-----

-------------- next part --------------
A non-text attachment was scrubbed...
Name: time_is_not_time.diff
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20090512/7506c757/attachment.bin>
-------------- next part --------------
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list