From 8389d01998758e222934bee50a38457d8f7b0661 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 10 Aug 2016 17:14:10 +0200 Subject: [PATCH] Fix flexible downtimes expiry time and removal fixes #12395 --- lib/icinga/checkable.cpp | 4 ++++ lib/icinga/downtime.cpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/icinga/checkable.cpp b/lib/icinga/checkable.cpp index f13ea34e4..73bf6afa3 100644 --- a/lib/icinga/checkable.cpp +++ b/lib/icinga/checkable.cpp @@ -153,6 +153,10 @@ void Checkable::NotifyDowntimeInternal(const Downtime::Ptr& downtime) void Checkable::NotifyDowntimeEnd(const Downtime::Ptr& downtime) { + /* don't send notifications for flexible downtimes which never triggered */ + if (!downtime->GetFixed() && !downtime->IsTriggered()) + return; + Checkable::Ptr checkable = downtime->GetCheckable(); if (!checkable->IsPaused()) diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp index c903ab5db..a17952672 100644 --- a/lib/icinga/downtime.cpp +++ b/lib/icinga/downtime.cpp @@ -180,7 +180,20 @@ bool Downtime::IsTriggered(void) const bool Downtime::IsExpired(void) const { - return (GetEndTime() < Utility::GetTime()); + double now = Utility::GetTime(); + + if (GetFixed()) + return (GetEndTime() < now); + else { + /* triggered flexible downtime not in effect anymore */ + if (IsTriggered() && !IsInEffect()) + return true; + /* flexible downtime never triggered */ + else if (!IsTriggered() && (GetEndTime() < now)) + return true; + else + return false; + } } int Downtime::GetNextDowntimeID(void)