From 4fe677b87b9b982e4dd022bf459dc5934eaf9159 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 9 Jun 2020 14:35:40 +0200 Subject: [PATCH] Recognize PENDING -> UNKNOWN as state change ... to get notified about that state change. refs #7807 --- lib/icinga/checkable-check.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index da1e8bd397f..fe51c6906ee 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -222,7 +222,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig } /* SOFT state change, increase attempt counter. */ - if (old_stateType == StateTypeSoft && !IsStateOK(old_state)) { + if (old_stateType == StateTypeSoft && old_cr && !IsStateOK(old_state)) { SetStateType(StateTypeSoft); attempt = old_attempt + 1; } @@ -266,11 +266,15 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig bool stateChange; - /* Exception on state change calculation for hosts. */ - if (checkableType == CheckableService) - stateChange = (old_state != new_state); - else - stateChange = (Host::CalculateState(old_state) != Host::CalculateState(new_state)); + if (old_cr) { + /* Exception on state change calculation for hosts. */ + if (checkableType == CheckableService) + stateChange = (old_state != new_state); + else + stateChange = (Host::CalculateState(old_state) != Host::CalculateState(new_state)); + } else { + stateChange = true; + } /* Store the current last state change for the next iteration. */ SetPreviousStateChange(GetLastStateChange()); @@ -304,9 +308,9 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig if (GetAcknowledgement() == AcknowledgementNone) remove_acknowledgement_comments = true; - bool hardChange = (GetStateType() == StateTypeHard && old_stateType == StateTypeSoft); + bool hardChange = (GetStateType() == StateTypeHard && old_stateType == StateTypeSoft && old_cr); - if (stateChange && old_stateType == StateTypeHard && GetStateType() == StateTypeHard) + if (stateChange && (old_stateType == StateTypeHard || !old_cr) && GetStateType() == StateTypeHard) hardChange = true; bool is_volatile = GetVolatile();