[icinga-checkins] icinga.org: icinga2/feature/escalation-notification-5011: Implement one-time notification for escalation contacts.

git at icinga.org git at icinga.org
Fri Nov 8 14:01:18 CET 2013


Module: icinga2
Branch: feature/escalation-notification-5011
Commit: 2dce4855b7245b981621a7f4a0e2d33288b958e9
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2dce4855b7245b981621a7f4a0e2d33288b958e9

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Wed Nov  6 08:36:22 2013 +0100

Implement one-time notification for escalation contacts.

---

 components/notification/notificationcomponent.cpp |   11 ++++-------
 lib/icinga/notification.cpp                       |    6 +++++-
 lib/icinga/notification.ti                        |    3 ++-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/components/notification/notificationcomponent.cpp b/components/notification/notificationcomponent.cpp
index b3d3d10..cea2b66 100644
--- a/components/notification/notificationcomponent.cpp
+++ b/components/notification/notificationcomponent.cpp
@@ -56,15 +56,12 @@ void NotificationComponent::NotificationTimerHandler(void)
 	double now = Utility::GetTime();
 
 	BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjects<Notification>()) {
-		if (notification->GetNotificationInterval() <= 0)
-			continue;
+		Service::Ptr service = notification->GetService();
 
-		if (notification->GetNextNotification() > now)
+		if (notification->GetNotificationInterval() <= 0 && notification->GetLastProblemNotification() < service->GetLastHardStateChange())
 			continue;
 
-		Service::Ptr service = notification->GetService();
-
-		if (!service)
+		if (notification->GetNextNotification() > now)
 			continue;
 
 		bool reachable = service->IsReachable();
@@ -107,5 +104,5 @@ void NotificationComponent::NotificationTimerHandler(void)
 void NotificationComponent::SendNotificationsHandler(const Service::Ptr& service, NotificationType type,
     const Dictionary::Ptr& cr, const String& author, const String& text)
 {
-	service->SendNotifications(static_cast<NotificationType>(type), cr, author, text);
+	service->SendNotifications(type, cr, author, text);
 }
diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp
index 53e9141..2b53c6b 100644
--- a/lib/icinga/notification.cpp
+++ b/lib/icinga/notification.cpp
@@ -217,7 +217,11 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction
 	{
 		ObjectLock olock(this);
 
-		SetLastNotification(Utility::GetTime());
+		double now = Utility::GetTime();
+		SetLastNotification(now);
+
+		if (type == NotificationProblem)
+			SetLastProblemNotification(now);
 	}
 
 	std::set<User::Ptr> allUsers;
diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti
index d7cf424..e6b299b 100644
--- a/lib/icinga/notification.ti
+++ b/lib/icinga/notification.ti
@@ -26,6 +26,7 @@ class Notification : DynamicObject
 	[state] double last_notification;
 	[state, set_protected] double next_notification (NextNotificationRaw);
 	[state, set_protected] Value notification_number;
+	[state] double last_problem_notification;
 };
 
-}
\ No newline at end of file
+}





More information about the icinga-checkins mailing list