]> granicus.if.org Git - icinga2/commitdiff
Fix incorrect behavior for max_check_attempts
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 8 Aug 2016 09:02:08 +0000 (11:02 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 8 Aug 2016 09:02:08 +0000 (11:02 +0200)
fixes #11898

lib/icinga/checkable-check.cpp

index a56554f63f7c45933b3e6d3884db311c794be76e..299e9f216d6c7d46989c8173e416df69db30228c 100644 (file)
@@ -177,9 +177,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
 
        std::set<Checkable::Ptr> children = GetChildren();
 
-       if (!old_cr) {
-               SetStateType(StateTypeSoft);
-       } else if (IsStateOK(cr->GetState())) {
+       if (IsStateOK(cr->GetState())) {
                SetStateType(StateTypeHard); // NOT-OK -> HARD OK
 
                if (!IsStateOK(old_state))
@@ -192,7 +190,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
                if (!children.empty())
                        OnReachabilityChanged(this, cr, children, origin);
        } else {
-               if (old_attempt >= GetMaxCheckAttempts()) {
+               if (old_attempt + 1 >= GetMaxCheckAttempts()) {
                        SetStateType(StateTypeHard);
                } else if (old_stateType == StateTypeSoft && !IsStateOK(old_state)) {
                        SetStateType(StateTypeSoft);
@@ -284,9 +282,6 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
                        send_notification = true;
        }
 
-       if (!old_cr)
-               send_notification = false; /* Don't send notifications for the initial state change */
-
        if (IsStateOK(old_state) && old_stateType == StateTypeSoft)
                send_notification = false; /* Don't send notifications for SOFT-OK -> HARD-OK. */