]> granicus.if.org Git - icinga2/blobdiff - lib/icinga/checkable.cpp
Re-send suppressed notifications
[icinga2] / lib / icinga / checkable.cpp
index a4c62500ec30ac4c1051f915e7094fa799ca33c5..c4265d05f266ecb766577e6da45bc24488d7f9c1 100644 (file)
@@ -7,6 +7,8 @@
 #include "base/objectlock.hpp"
 #include "base/utility.hpp"
 #include "base/exception.hpp"
+#include "base/timer.hpp"
+#include <boost/thread/once.hpp>
 
 using namespace icinga;
 
@@ -16,6 +18,8 @@ INITIALIZE_ONCE(&Checkable::StaticInitialize);
 boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, bool, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
 boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
 
+static Timer::Ptr l_CheckablesFireSuppressedNotifications;
+
 void Checkable::StaticInitialize()
 {
        /* fixed downtime start */
@@ -65,6 +69,15 @@ void Checkable::Start(bool runtimeCreated)
        }
 
        ObjectImpl<Checkable>::Start(runtimeCreated);
+
+       static boost::once_flag once = BOOST_ONCE_INIT;
+
+       boost::call_once(once, []() {
+               l_CheckablesFireSuppressedNotifications = new Timer();
+               l_CheckablesFireSuppressedNotifications->SetInterval(5);
+               l_CheckablesFireSuppressedNotifications->OnTimerExpired.connect(&Checkable::FireSuppressedNotifications);
+               l_CheckablesFireSuppressedNotifications->Start();
+       });
 }
 
 void Checkable::AddGroup(const String& name)
@@ -139,6 +152,16 @@ int Checkable::GetSeverity() const
        return 0;
 }
 
+bool Checkable::GetProblem() const
+{
+       return !IsStateOK(GetStateRaw());
+}
+
+bool Checkable::GetHandled() const
+{
+       return GetProblem() && (IsInDowntime() || IsAcknowledged());
+}
+
 void Checkable::NotifyFixedDowntimeStart(const Downtime::Ptr& downtime)
 {
        if (!downtime->GetFixed())