From c6e8013238130c070084b87f8b32fbdd6e2b674c Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 11 Feb 2013 16:38:16 +0100 Subject: [PATCH] Don't send notifications for services that are unreachable, in a downtime or acknowledged. --- lib/icinga/service-check.cpp | 3 ++- lib/icinga/service.cpp | 5 +++++ lib/icinga/service.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index 5838bb9ee..a27d567b9 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -353,7 +353,8 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr) * state/state_type attributes. */ DynamicObject::FlushTx(); - RequestNotifications(NotificationStateChange); + if (IsReachable() && !IsInDowntime() && !IsAcknowledged()) + RequestNotifications(NotificationStateChange); } } diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index bf712f971..26719f0ed 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -190,6 +190,11 @@ void Service::SetAcknowledgement(AcknowledgementType acknowledgement) Set("acknowledgement", static_cast(acknowledgement)); } +bool Service::IsAcknowledged(void) +{ + return GetAcknowledgement() != AcknowledgementNone; +} + double Service::GetAcknowledgementExpiry(void) const { Value value = Get("acknowledgement_expiry"); diff --git a/lib/icinga/service.h b/lib/icinga/service.h index d9f93fe6b..18826477e 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -208,6 +208,7 @@ public: static void ValidateDowntimeCache(void); bool IsInDowntime(void) const; + bool IsAcknowledged(void); /* Comments */ static int GetNextCommentID(void); -- 2.40.0