]> granicus.if.org Git - icinga2/commitdiff
Don't increment check attempt counter on OK->NOT-OK transition
authorMichael Friedrich <michael.friedrich@gmail.com>
Fri, 20 Feb 2015 20:30:14 +0000 (21:30 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Fri, 21 Aug 2015 08:24:49 +0000 (10:24 +0200)
This fixes the problem that the first SOFT state is actually considered
the second state.

refs #7287
fixes #9897

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>
lib/icinga/checkable-check.cpp

index bc4cacd12c4e24ca237842b98ad07686dcb9ff83..13f0b28088ae43c8a33f892b3bcdaed61a206a54 100644 (file)
@@ -319,9 +319,12 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
        } else {
                if (old_attempt >= GetMaxCheckAttempts()) {
                        SetStateType(StateTypeHard);
-               } else if (old_stateType == StateTypeSoft || old_state == ServiceOK) {
+               } else if (old_stateType == StateTypeSoft && old_state != ServiceOK) {
                        SetStateType(StateTypeSoft);
-                       attempt = old_attempt + 1;
+                       attempt = old_attempt + 1; //NOT-OK -> NOT-OK counter
+               } else if (old_state == ServiceOK) {
+                       SetStateType(StateTypeSoft);
+                       attempt = 1; //OK -> NOT-OK transition, reset the counter
                } else {
                        attempt = old_attempt;
                }