Fix notification timer for notifications with interval <= 0.

Fixes #5785
This commit is contained in:
Gunnar Beutner 2014-04-09 15:51:10 +02:00
parent 5dbf8f95de
commit 103d95d0df

View File

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