Re: [Nagios-devel] [PATCH] notifications: Fix

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

Re: [Nagios-devel] [PATCH] notifications: Fix

Post by Guest »

Here is full background on this bug.=0A=0AThese two sections of code in bas=
e/notifications.c are broken:=0A=0A--------=0A /* see if enough time=
has elapsed for first notification (Mathias Sundman) */=0A /* 10/02=
/07 don't place restrictions on recoveries or non-normal notifications, mus=
t use last time ok (or program start) in calculation */=0A /* it is =
reasonable to assume that if the host was never up, the program start time =
should be used in this calculation */=0A if(type =3D=3D NOTIFICATION=
_NORMAL && svc->current_notification_number =3D=3D 0 && svc->current_state =
!=3D STATE_OK) {=0A=0A /* determine the time to use of the f=
irst problem point */=0A first_problem_time =3D svc->last_ti=
me_ok; /* not accurate, but its the earliest time we could use in the compa=
rison */=0A if((svc->last_time_warning last_time_warning > svc->last_time_ok))=0A =
first_problem_time =3D svc->last_time_warning;=0A if((svc->=
last_time_unknown last_time_unknown > svc->l=
ast_time_ok))=0A first_problem_time =3D svc->last_ti=
me_unknown;=0A if((svc->last_time_critical last_time_critical > svc->last_time_ok))=0A =
first_problem_time =3D svc->last_time_critical;=0A=0A =
if(current_time first_notification_delay * int=
erval_length)) {=0A log_debug_info(DEBUGL_NOTIFICATI=
ONS, 1, "Not enough time has elapsed since the service changed to a non-OK =
state, so we should not notify about this problem yet\n");=0A =
return ERROR;=0A }=0A }=0A=
=0A--------=0A /* see if enough time has elapsed for first notificat=
ion (Mathias Sundman) */=0A /* 10/02/07 don't place restrictions on =
recoveries or non-normal notifications, must use last time up (or program s=
tart) in calculation */=0A /* it is reasonable to assume that if the=
host was never up, the program start time should be used in this calculati=
on */=0A if(type =3D=3D NOTIFICATION_NORMAL && hst->current_notifica=
tion_number =3D=3D 0 && hst->current_state !=3D HOST_UP) {=0A=0A =
/* determine the time to use of the first problem point */=0A =
first_problem_time =3D hst->last_time_up; /* not accurate, but its t=
he earliest time we could use in the comparison */=0A if((hs=
t->last_time_down last_time_down > hst->last=
_time_up))=0A first_problem_time =3D hst->last_time_=
down;=0A if((hst->last_time_unreachable last_time_unreachable > hst->last_time_unreachable))=0A =
first_problem_time =3D hst->last_time_unreachable;=0A=0A =
if(current_time first_notification=
_delay * interval_length)) {=0A log_debug_info(DEBUG=
L_NOTIFICATIONS, 1, "Not enough time has elapsed since the host changed to =
a non-UP state (or since program start), so we shouldn't notify about this =
problem yet.\n");=0A return ERROR;=0A =
}=0A }=0A--------=0A=0AIf you look at it closely, y=
ou'll see that most of the central if()'s=0Aare really just instances of:=
=0A=0A if (B A) ...=0A=0Awhich of course will never be satisf=
ied, given the original value of=0Afirst_problem_time. And the second simi=
lar if() in the second section=0Ais really:=0A=0A if (B B) ..=
.=0A=0Awhich is certainly non-functional.=0A=0ABug history:=0A=0AA problem =
reported by Pawel Malachowski, May 20, 2010:=0Ahttp://comments.gmane.org/gm=
ane.network.nagios.devel/7402=0A=0AEthan Galstad's code change trying to ad=
dress the

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: eponymousalias@yahoo.com
Locked