diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp index a17952672..24b531214 100644 --- a/lib/icinga/downtime.cpp +++ b/lib/icinga/downtime.cpp @@ -20,6 +20,7 @@ #include "icinga/downtime.hpp" #include "icinga/downtime.tcpp" #include "icinga/host.hpp" +#include "icinga/scheduleddowntime.hpp" #include "remote/configobjectutility.hpp" #include "base/configtype.hpp" #include "base/utility.hpp" @@ -196,6 +197,17 @@ bool Downtime::IsExpired(void) const } } +bool Downtime::HasValidConfigOwner(void) const +{ + String configOwner = GetConfigOwner(); + + if (!configOwner.IsEmpty()) { + return (GetObject("ScheduledDowntime", configOwner) != ScheduledDowntime::Ptr()); + } + + return true; +} + int Downtime::GetNextDowntimeID(void) { boost::mutex::scoped_lock lock(l_DowntimeMutex); @@ -375,7 +387,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()) + if (downtime->IsActive() && (downtime->IsExpired() || !downtime->HasValidConfigOwner())) RemoveDowntime(downtime->GetName(), false, true); } } diff --git a/lib/icinga/downtime.hpp b/lib/icinga/downtime.hpp index f52a99aca..8122ebe32 100644 --- a/lib/icinga/downtime.hpp +++ b/lib/icinga/downtime.hpp @@ -48,6 +48,7 @@ public: bool IsInEffect(void) const; bool IsTriggered(void) const; bool IsExpired(void) const; + bool HasValidConfigOwner(void) const; static int GetNextDowntimeID(void);