Fix incorrect notifications for soft recoveries

fixes #12529
This commit is contained in:
Gunnar Beutner 2016-08-24 11:13:19 +02:00
parent a14add3411
commit deb938d412

View File

@ -183,7 +183,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
if (IsStateOK(cr->GetState())) { if (IsStateOK(cr->GetState())) {
SetStateType(StateTypeHard); // NOT-OK -> HARD OK SetStateType(StateTypeHard); // NOT-OK -> HARD OK
if (old_stateType == StateTypeHard && !IsStateOK(old_state)) if (!IsStateOK(old_state))
recovery = true; recovery = true;
ResetNotificationNumbers(); ResetNotificationNumbers();
@ -278,7 +278,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
if (notification_reachable && !in_downtime && !IsAcknowledged()) { if (notification_reachable && !in_downtime && !IsAcknowledged()) {
/* Send notifications whether when a hard state change occured. */ /* Send notifications whether when a hard state change occured. */
if (hardChange) if (hardChange && !(old_stateType == StateTypeSoft && IsStateOK(new_state)))
send_notification = true; send_notification = true;
/* Or if the checkable is volatile and in a HARD state. */ /* Or if the checkable is volatile and in a HARD state. */
else if (is_volatile && GetStateType() == StateTypeHard) else if (is_volatile && GetStateType() == StateTypeHard)
@ -383,17 +383,9 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
NotifyFlapping(origin); NotifyFlapping(origin);
} }
if (recovery) { if (send_notification && !is_flapping) {
/* Recovery notifications must be sent any time.
* Users who where notified about a problem before
* will be filtered when processing the notification.
*/
if (!IsPaused()) if (!IsPaused())
OnNotificationsRequested(this, NotificationRecovery, cr, "", "", MessageOrigin::Ptr()); OnNotificationsRequested(this, recovery ? NotificationRecovery : NotificationProblem, cr, "", "", MessageOrigin::Ptr());
} else if (send_notification && !is_flapping) {
/* Problem notifications */
if (!IsPaused())
OnNotificationsRequested(this, NotificationProblem, cr, "", "", MessageOrigin::Ptr());
} }
} }