]> granicus.if.org Git - icinga2/commitdiff
Bugfixes for the soft/hard state calculation.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 25 Jun 2012 13:54:50 +0000 (15:54 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 25 Jun 2012 14:03:05 +0000 (16:03 +0200)
icinga/service.cpp

index cf9fc5d06e90a7a92f3540eb0e04686b038383ff..9df1c581e0527d93934e79b3bc4a3443be9eb3ff 100644 (file)
@@ -102,7 +102,7 @@ void Service::SetCurrentCheckAttempt(long attempt)
 
 long Service::GetCurrentCheckAttempt(void) const
 {
-       long value = 0;
+       long value = 1;
        GetConfigObject()->GetTag("check_attempt", &value);
        return value;
 }
@@ -135,24 +135,22 @@ void Service::ApplyCheckResult(const CheckResult& cr)
 {
        long attempt = GetCurrentCheckAttempt();
 
-       if (GetState() == StateOK && cr.GetState() == StateOK) {
-               SetStateType(StateTypeHard);
-               SetCurrentCheckAttempt(0);
-       } else if (GetState() == StateOK && cr.GetState() != StateOK) {
-               attempt++;
+       if (cr.GetState() == StateOK) {
+               if (GetState() == StateOK)
+                       SetStateType(StateTypeHard);
 
+               attempt = 1;
+       } else {
                if (attempt >= GetMaxCheckAttempts()) {
                        SetStateType(StateTypeHard);
-                       attempt = 0;
-               } else {
+                       attempt = 1;
+               } else if (GetStateType() == StateTypeSoft || GetState() == StateOK) {
                        SetStateType(StateTypeSoft);
+                       attempt++;
                }
-
-               SetCurrentCheckAttempt(attempt);
-       } else if (GetState() != StateOK && cr.GetState() == StateOK) {
-               SetState(StateOK);
        }
 
+       SetCurrentCheckAttempt(attempt);
        SetState(cr.GetState());
 }