[icinga-checkins] icinga.org: icinga2/master: Fix flexible downtimes expiry time and removal

git at icinga.org git at icinga.org
Wed Aug 10 17:15:48 CEST 2016


Module: icinga2
Branch: master
Commit: 8389d01998758e222934bee50a38457d8f7b0661
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=8389d01998758e222934bee50a38457d8f7b0661

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Wed Aug 10 17:14:10 2016 +0200

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 f13ea34..73bf6af 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 c903ab5..a179526 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)



More information about the icinga-checkins mailing list