[Nagios-devel] [RFC] - strange issue on notification filter aka

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [RFC] - strange issue on notification filter aka

Post by Guest »

This is a multi-part message in MIME format.
--------------080305070206080300050602
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

-----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-----


--------------080305070206080300050602
Content-Type: text/x-patch;
name="time_is_not_time.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="time_is_not_time.diff"

diff --git a/base/notifications.c b/base/notifications.c
index d8ccbaf..bd15824 100644
--- a/base/notifications.c

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked