]> granicus.if.org Git - icinga2/commitdiff
Implement one-time notification for escalation contacts.
authorGunnar Beutner <gunnar@beutner.name>
Wed, 6 Nov 2013 07:36:22 +0000 (08:36 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 11 Nov 2013 10:21:23 +0000 (11:21 +0100)
Fixes #5011

components/notification/notificationcomponent.cpp
lib/icinga/notification.cpp
lib/icinga/notification.ti

index 9d712f34a7e902b1451368417a2b3f348bf6f7c4..f92d690f57c857d109ed8acdc60452c688607829 100644 (file)
@@ -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 CheckResult::Ptr& cr, const String& author, const String& text)
 {
-       service->SendNotifications(static_cast<NotificationType>(type), cr, author, text);
+       service->SendNotifications(type, cr, author, text);
 }
index f6204ca188d1920f6ac81976a14cf4c533ac55e9..f22efb822d7b71cb3c8b8772f004d9fa2d8cd95a 100644 (file)
@@ -217,7 +217,11 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
        {
                ObjectLock olock(this);
 
-               SetLastNotification(Utility::GetTime());
+               double now = Utility::GetTime();
+               SetLastNotification(now);
+
+               if (type == NotificationProblem)
+                       SetLastProblemNotification(now);
        }
 
        std::set<User::Ptr> allUsers;
index d7cf424e9e3b60445cb00a48fec0dbf1e0088bbc..e6b299b4de9b3ecc9419f2d8b22884345f1dfd33 100644 (file)
@@ -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
+}