]> granicus.if.org Git - icinga2/commitdiff
Fix notification timer for notifications with interval <= 0.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 9 Apr 2014 13:51:10 +0000 (15:51 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 9 Apr 2014 13:51:10 +0000 (15:51 +0200)
Fixes #5785

components/notification/notificationcomponent.cpp

index 80b541534e422cf9ac3716246be198ee2b061d1c..b16fa94d38b83023ab7cb3a60321ddf8ca8e1949 100644 (file)
@@ -74,13 +74,13 @@ void NotificationComponent::NotificationTimerHandler(void)
        BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjects<Notification>()) {
                Checkable::Ptr checkable = notification->GetCheckable();
 
-               if (notification->GetInterval() <= 0 && notification->GetLastProblemNotification() < checkable->GetLastHardStateChange())
+               if (notification->GetInterval() <= 0 && notification->GetLastProblemNotification() > checkable->GetLastHardStateChange())
                        continue;
 
                if (notification->GetNextNotification() > now)
                        continue;
 
-               bool reachable = checkable->IsReachable();
+               bool reachable = checkable->IsReachable(DependencyNotification);
 
                {
                        ObjectLock olock(notification);
@@ -88,29 +88,22 @@ void NotificationComponent::NotificationTimerHandler(void)
                }
 
                {
+                       Host::Ptr host;
+                       Service::Ptr service;
+                       tie(host, service) = GetHostService(checkable);
+
                        ObjectLock olock(checkable);
 
                        if (checkable->GetStateType() == StateTypeSoft)
                                continue;
 
-                       Service::Ptr service = dynamic_pointer_cast<Service>(checkable);
-
-                       if (service) {
-                                if (service->GetState() == ServiceOK)
-                                       continue;
-                       } else {
-                               Host::Ptr host = static_pointer_cast<Host>(checkable);
-
-                               if (host->GetState() == HostUp)
-                                       continue;
-                       }
+                       if ((service && service->GetState() == ServiceOK) || (!service && host->GetState() == HostUp))
+                               continue;
 
                        if (!reachable || checkable->IsInDowntime() || checkable->IsAcknowledged())
                                continue;
                }
 
-               notification->SetLastProblemNotification(now);
-
                try {
                        Log(LogInformation, "notification", "Sending reminder notification for object '" + checkable->GetName() + "'");
                        notification->BeginExecuteNotification(NotificationProblem, checkable->GetLastCheckResult(), false);