From: <est...@us...> - 2013-05-06 00:40:46
|
Revision: 2753 http://nagios.svn.sourceforge.net/nagios/?rev=2753&view=rev Author: estanley375 Date: 2013-05-06 00:40:40 +0000 (Mon, 06 May 2013) Log Message: ----------- Forward patch of SVN revision 2752 Revision Links: -------------- http://nagios.svn.sourceforge.net/nagios/?rev=2752&view=rev Modified Paths: -------------- nagioscore/trunk/common/downtime.c Modified: nagioscore/trunk/common/downtime.c =================================================================== --- nagioscore/trunk/common/downtime.c 2013-05-06 00:38:36 UTC (rev 2752) +++ nagioscore/trunk/common/downtime.c 2013-05-06 00:40:40 UTC (rev 2753) @@ -343,21 +343,29 @@ } } - if((FALSE == temp_downtime->fixed) && (FALSE == was_in_effect)) { - /* increment pending flex downtime counter */ - if(temp_downtime->type == HOST_DOWNTIME) - hst->pending_flex_downtime++; - else - svc->pending_flex_downtime++; - temp_downtime->incremented_pending_downtime = TRUE; + /* If the downtime is triggered and was in effect, mark it as not in + effect so it gets scheduled correctly */ + if((temp_downtime->triggered_by != 0) && + (TRUE == temp_downtime->is_in_effect)) { + was_in_effect = temp_downtime->is_in_effect; + temp_downtime->is_in_effect = FALSE; + } - /* Since a flex downtime may never start, schedule an expiring event in - case the event is never triggered. The expire event will NOT cancel - a downtime event that is in effect */ - log_debug_info(DEBUGL_DOWNTIME, 1, "Scheduling downtime expire event in case flexible downtime is never triggered\n"); - temp_downtime->stop_event = schedule_new_event(EVENT_EXPIRE_DOWNTIME, TRUE, (temp_downtime->end_time + 1), FALSE, 0, NULL, FALSE, NULL, NULL, 0); - } + if((FALSE == temp_downtime->fixed) && (FALSE == was_in_effect)) { + /* increment pending flex downtime counter */ + if(temp_downtime->type == HOST_DOWNTIME) + hst->pending_flex_downtime++; + else + svc->pending_flex_downtime++; + temp_downtime->incremented_pending_downtime = TRUE; + /* Since a flex downtime may never start, schedule an expiring event in + case the event is never triggered. The expire event will NOT cancel + a downtime event that is in effect */ + log_debug_info(DEBUGL_DOWNTIME, 1, "Scheduling downtime expire event in case flexible downtime is never triggered\n"); + temp_downtime->stop_event = schedule_new_event(EVENT_EXPIRE_DOWNTIME, TRUE, (temp_downtime->end_time + 1), FALSE, 0, NULL, FALSE, NULL, NULL, 0); + } + #ifdef PROBABLY_NOT_NEEDED /*** FLEXIBLE DOWNTIME SANITY CHECK - ADDED 02/17/2008 ****/ @@ -1096,6 +1104,39 @@ static int downtime_compar(const void *p1, const void *p2) { scheduled_downtime *d1 = *(scheduled_downtime **)p1; scheduled_downtime *d2 = *(scheduled_downtime **)p2; + + /* + If the start times of two downtimes are equal and one is triggered but + but the other is not, the triggered downtime should be later in the + list than the untriggered one. This is so they are written to the + retention.dat and status.dat in the correct order. + + Previously the triggered downtime always appeared before its + triggering downtime in those files. When the downtimes were read + from those files, either on a core restart or by the CGIs, the + triggered downtime would be discarded because the triggering + downtime did not yet exist. + + The most common case for this is when a downtime is created and + the option is selected to create triggered downtimes on all child + objects. This change in the sort order does NOT resolve the + case where a manually created, triggered downtime is created with + a start time earlier than the triggering downtime. + + This would need to be resolved by comparing the triggered_by value + with the downtime ID regardless of the start time. However, this + should be a relatively rare case and only caused by intentional + scheduling by a human. This change was not implemented because it + would cause the downtime list to be out of time order and the + implications of this were not well understood. + */ + + if(d1->start_time == d2->start_time) { + if(( d1->triggered_by == 0 && d2->triggered_by != 0) || + ( d1->triggered_by != 0 && d2->triggered_by == 0)) { + return d1->triggered_by == 0 ? -1 : 1; + } + } return (d1->start_time < d2->start_time) ? -1 : (d1->start_time - d2->start_time); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |