[icinga-checkins] icinga.org: icinga2/master: Fix: Expired downtimes are not removed

git at icinga.org git at icinga.org
Mon May 2 15:33:43 CEST 2016


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Mon May  2 15:32:46 2016 +0200

Fix: Expired downtimes are not removed

fixes #11711

---

 lib/compat/statusdatawriter.cpp   |    2 +-
 lib/db_ido/dbevents.cpp           |    4 ++--
 lib/icinga/checkable-downtime.cpp |    4 ++--
 lib/icinga/comment.cpp            |    1 +
 lib/icinga/downtime.cpp           |    5 +++--
 lib/icinga/downtime.hpp           |    2 +-
 lib/livestatus/downtimestable.cpp |    2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp
index 134174f..d6073f5 100644
--- a/lib/compat/statusdatawriter.cpp
+++ b/lib/compat/statusdatawriter.cpp
@@ -181,7 +181,7 @@ void StatusDataWriter::DumpDowntimes(std::ostream& fp, const Checkable::Ptr& che
 		      "\t" "triggered_by=" << triggeredByLegacy << "\n"
 		      "\t" "fixed=" << static_cast<long>(downtime->GetFixed()) << "\n"
 		      "\t" "duration=" << static_cast<long>(downtime->GetDuration()) << "\n"
-		      "\t" "is_in_effect=" << (downtime->IsActive() ? 1 : 0) << "\n"
+		      "\t" "is_in_effect=" << (downtime->IsInEffect() ? 1 : 0) << "\n"
 		      "\t" "author=" << downtime->GetAuthor() << "\n"
 		      "\t" "comment=" << downtime->GetComment() << "\n"
 		      "\t" "trigger_time=" << downtime->GetTriggerTime() << "\n"
diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp
index 1afbe9c..fc870f7 100644
--- a/lib/db_ido/dbevents.cpp
+++ b/lib/db_ido/dbevents.cpp
@@ -506,7 +506,7 @@ void DbEvents::AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime
 	fields1->Set("scheduled_start_time", DbValue::FromTimestamp(downtime->GetStartTime()));
 	fields1->Set("scheduled_end_time", DbValue::FromTimestamp(downtime->GetEndTime()));
 	fields1->Set("was_started", ((downtime->GetStartTime() <= Utility::GetTime()) ? 1 : 0));
-	fields1->Set("is_in_effect", (downtime->IsActive() ? 1 : 0));
+	fields1->Set("is_in_effect", (downtime->IsInEffect() ? 1 : 0));
 	fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
 	fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
 
@@ -658,7 +658,7 @@ void DbEvents::TriggerDowntime(const Downtime::Ptr& downtime)
 	fields1->Set("was_started", 1);
 	fields1->Set("actual_start_time", DbValue::FromTimestamp(time_bag.first));
 	fields1->Set("actual_start_time_usec", time_bag.second);
-	fields1->Set("is_in_effect", (downtime->IsActive() ? 1 : 0));
+	fields1->Set("is_in_effect", (downtime->IsInEffect() ? 1 : 0));
 	fields1->Set("trigger_time", DbValue::FromTimestamp(downtime->GetTriggerTime()));
 	fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
 
diff --git a/lib/icinga/checkable-downtime.cpp b/lib/icinga/checkable-downtime.cpp
index 82c0110..f1eec03 100644
--- a/lib/icinga/checkable-downtime.cpp
+++ b/lib/icinga/checkable-downtime.cpp
@@ -44,7 +44,7 @@ void Checkable::TriggerDowntimes(void)
 bool Checkable::IsInDowntime(void) const
 {
 	BOOST_FOREACH(const Downtime::Ptr& downtime, GetDowntimes()) {
-		if (downtime->IsActive())
+		if (downtime->IsInEffect())
 			return true;
 	}
 
@@ -56,7 +56,7 @@ int Checkable::GetDowntimeDepth(void) const
 	int downtime_depth = 0;
 
 	BOOST_FOREACH(const Downtime::Ptr& downtime, GetDowntimes()) {
-		if (downtime->IsActive())
+		if (downtime->IsInEffect())
 			downtime_depth++;
 	}
 
diff --git a/lib/icinga/comment.cpp b/lib/icinga/comment.cpp
index 85c5f1a..eeb7b2b 100644
--- a/lib/icinga/comment.cpp
+++ b/lib/icinga/comment.cpp
@@ -244,6 +244,7 @@ void Comment::CommentsExpireTimerHandler(void)
 	}
 
 	BOOST_FOREACH(const Comment::Ptr& comment, comments) {
+		/* Only remove comment which are activated after daemon start. */
 		if (comment->IsActive() && comment->IsExpired())
 			RemoveComment(comment->GetName());
 	}
diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp
index 2d18383..62bdb7c 100644
--- a/lib/icinga/downtime.cpp
+++ b/lib/icinga/downtime.cpp
@@ -150,7 +150,7 @@ Checkable::Ptr Downtime::GetCheckable(void) const
 	return static_pointer_cast<Checkable>(m_Checkable);
 }
 
-bool Downtime::IsActive(void) const
+bool Downtime::IsInEffect(void) const
 {
 	double now = Utility::GetTime();
 
@@ -294,7 +294,7 @@ void Downtime::RemoveDowntime(const String& id, bool cancelled, bool expired, co
 
 void Downtime::TriggerDowntime(void)
 {
-	if (IsActive() && IsTriggered()) {
+	if (IsInEffect() && IsTriggered()) {
 		Log(LogDebug, "Downtime")
 		    << "Not triggering downtime '" << GetName() << "': already triggered.";
 		return;
@@ -358,6 +358,7 @@ void Downtime::DowntimesExpireTimerHandler(void)
 	}
 
 	BOOST_FOREACH(const Downtime::Ptr& downtime, downtimes) {
+		/* Only remove downtimes which are activated after daemon start. */
 		if (downtime->IsActive() && downtime->IsExpired())
 			RemoveDowntime(downtime->GetName(), false, true);
 	}
diff --git a/lib/icinga/downtime.hpp b/lib/icinga/downtime.hpp
index c2185cc..e2ef520 100644
--- a/lib/icinga/downtime.hpp
+++ b/lib/icinga/downtime.hpp
@@ -45,7 +45,7 @@ public:
 
 	intrusive_ptr<Checkable> GetCheckable(void) const;
 
-	bool IsActive(void) const;
+	bool IsInEffect(void) const;
 	bool IsTriggered(void) const;
 	bool IsExpired(void) const;
 
diff --git a/lib/livestatus/downtimestable.cpp b/lib/livestatus/downtimestable.cpp
index a5798bf..db02a9e 100644
--- a/lib/livestatus/downtimestable.cpp
+++ b/lib/livestatus/downtimestable.cpp
@@ -129,7 +129,7 @@ Value DowntimesTable::TypeAccessor(const Value& row)
 {
 	Downtime::Ptr downtime = static_cast<Downtime::Ptr>(row);
 	// 1 .. active, 0 .. pending
-	return (downtime->IsActive() ? 1 : 0);
+	return (downtime->IsInEffect() ? 1 : 0);
 }
 
 Value DowntimesTable::IsServiceAccessor(const Value& row)



More information about the icinga-checkins mailing list