]> granicus.if.org Git - icinga2/commitdiff
Fix: Expired downtimes are not removed
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 2 May 2016 13:32:46 +0000 (15:32 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 2 May 2016 13:32:46 +0000 (15:32 +0200)
fixes #11711

lib/compat/statusdatawriter.cpp
lib/db_ido/dbevents.cpp
lib/icinga/checkable-downtime.cpp
lib/icinga/comment.cpp
lib/icinga/downtime.cpp
lib/icinga/downtime.hpp
lib/livestatus/downtimestable.cpp

index 134174f7018a8629ab0151c705d92c883dd16e75..d6073f57c80e45923d4b1466320492c471dd24ee 100644 (file)
@@ -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"
index 1afbe9c3bbca4d33c2586cef71358ebc154b4999..fc870f78aa27e7ac134d5b59071bb829ef9003ad 100644 (file)
@@ -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 */
 
index 82c0110bed707bc8534a28d789ef6d34d5d418ae..f1eec03ef6c7d082cad112f52a51524296c5b99d 100644 (file)
@@ -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++;
        }
 
index 85c5f1a17faf3aa9c68927cecb4b66baa668a8bf..eeb7b2b60b0ba09d8b31bb8ab3c00c17691f96a1 100644 (file)
@@ -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());
        }
index 2d18383028940e8e774af49ac070ce37c15d34e3..62bdb7c717d0f314b4b1f6191c63bfdab4efbd36 100644 (file)
@@ -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);
        }
index c2185cc75f84167e685d4d5e9549072bbbd93a1d..e2ef520f65e5a9f0bdb3a73f3a21839af4236b23 100644 (file)
@@ -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;
 
index a5798bfb9a8a6dabf56c846d61dba43799473e74..db02a9e4ef7b2c19ab3ed9be69ab156fc22615f7 100644 (file)
@@ -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)