Skip to content

Commit

Permalink
Recognize PENDING -> UNKNOWN as state change
Browse files Browse the repository at this point in the history
... to get notified about that state change.

refs #7807
  • Loading branch information
Al2Klimov committed Dec 14, 2020
1 parent b06ea2b commit 4fe677b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/icinga/checkable-check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 4fe677b

Please sign in to comment.