]> granicus.if.org Git - icinga2/commitdiff
Fixed soft service recoveries.
authorGunnar Beutner <gunnar.beutner@netways.de>
Sun, 10 Feb 2013 14:07:32 +0000 (15:07 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Sun, 10 Feb 2013 14:07:32 +0000 (15:07 +0100)
lib/icinga/service-check.cpp

index 41653fa71dfade07896fd5c1b5560c90500e6847..5838bb9ee45c4a06dcd95a8fe74b3889e707e704 100644 (file)
@@ -287,11 +287,15 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
 {
        ServiceState old_state = GetState();
        ServiceStateType old_stateType = GetStateType();
+       bool hardChange = false;
 
        long attempt = GetCurrentCheckAttempt();
 
        if (cr->Get("state") == StateOK) {
-               if (GetState() == StateOK)
+               if (old_state != StateOK && old_stateType == StateTypeHard)
+                       hardChange = true; // hard recovery
+
+               if (old_state == StateOK)
                        SetStateType(StateTypeHard);
 
                attempt = 1;
@@ -299,6 +303,7 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
                if (attempt >= GetMaxCheckAttempts()) {
                        SetStateType(StateTypeHard);
                        attempt = 1;
+                       hardChange = true;
                } else if (GetStateType() == StateTypeSoft || GetState() == StateOK) {
                        SetStateType(StateTypeSoft);
                        attempt++;
@@ -341,7 +346,7 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
        if (GetState() != StateOK)
                TriggerDowntimes();
 
-       if (GetStateType() == StateTypeHard && (old_state != GetState() || old_stateType == StateTypeSoft)) {
+       if (hardChange) {
                SetLastHardStateChange(now);
 
                /* Make sure the notification component sees the updated