[icinga-checkins] icinga.org: icinga2/master: Don' t send notifications for services that are unreachable, in a downtime or acknowledged.

git at icinga.org git at icinga.org
Mon Feb 11 16:41:31 CET 2013


Module: icinga2
Branch: master
Commit: c6e8013238130c070084b87f8b32fbdd6e2b674c
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=c6e8013238130c070084b87f8b32fbdd6e2b674c

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Feb 11 16:38:16 2013 +0100

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 deletions(-)

diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp
index 5838bb9..a27d567 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 bf712f9..26719f0 100644
--- a/lib/icinga/service.cpp
+++ b/lib/icinga/service.cpp
@@ -190,6 +190,11 @@ void Service::SetAcknowledgement(AcknowledgementType acknowledgement)
 	Set("acknowledgement", static_cast<long>(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 d9f93fe..1882647 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);





More information about the icinga-checkins mailing list