From 46659e75512d127020da9388f4d44610e3ab3215 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 17 Sep 2013 20:11:29 +0200 Subject: [PATCH] Add missing DowntimesExpireTimer. now the expired downtimes will get deleted every 60 seconds. fixes #4711 --- lib/icinga/service-downtime.cpp | 10 ++++++++++ lib/icinga/service.cpp | 2 ++ lib/icinga/service.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/lib/icinga/service-downtime.cpp b/lib/icinga/service-downtime.cpp index 1767f6ff2..a91aa7807 100644 --- a/lib/icinga/service-downtime.cpp +++ b/lib/icinga/service-downtime.cpp @@ -289,6 +289,16 @@ bool Service::IsDowntimeExpired(const Dictionary::Ptr& downtime) return (downtime->Get("end_time") < Utility::GetTime()); } +void Service::StartDowntimesExpiredTimer(void) +{ + if (!l_DowntimesExpireTimer) { + l_DowntimesExpireTimer = boost::make_shared(); + l_DowntimesExpireTimer->SetInterval(60); + l_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler)); + l_DowntimesExpireTimer->Start(); + } +} + void Service::AddDowntimesToCache(void) { Log(LogDebug, "icinga", "Updating Service downtimes cache."); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index d12bef569..34d9a2816 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -51,6 +51,8 @@ void Service::Start(void) AddDowntimesToCache(); AddCommentsToCache(); + + StartDowntimesExpiredTimer(); } void Service::OnConfigLoaded(void) diff --git a/lib/icinga/service.h b/lib/icinga/service.h index aeed0693f..14b8ffb34 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -275,6 +275,8 @@ public: static bool IsDowntimeTriggered(const Dictionary::Ptr& downtime); static bool IsDowntimeExpired(const Dictionary::Ptr& downtime); + void StartDowntimesExpiredTimer(void); + bool IsInDowntime(void) const; bool IsAcknowledged(void); -- 2.40.0