From f278181b8b0188095cf4c73b2e8c78aab5629f0a Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 20 Mar 2013 15:25:53 +0100 Subject: [PATCH] Fix recovery notifications for (SOFT-OK -> HARD-OK). Fixes #3876 --- lib/icinga/service-check.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index 0e0b444bf..e0e9948f6 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -146,7 +146,7 @@ void Service::UpdateNextCheck(void) double adj = 0; if (interval > 1) - adj = fmod(now * 1000 + GetSchedulingOffset(), interval * 1000) / 1000.0; + adj = fmod(now * 100 + GetSchedulingOffset(), interval * 100) / 100.0; SetNextCheck(now - adj + interval); } @@ -438,7 +438,6 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) ServiceState old_state = GetState(); StateType old_stateType = GetStateType(); long old_attempt = GetCurrentCheckAttempt(); - bool hardChange = false; bool recovery; /* The BeginExecuteCheck function already sets the old state, but we need to do it again @@ -450,14 +449,8 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) long attempt; if (cr->Get("state") == StateOK) { - if (old_state != StateOK && old_stateType == StateTypeHard) - SetStateType(StateTypeSoft); // HARD NON-OK -> SOFT OK - if (old_state == StateOK && old_stateType == StateTypeSoft) - hardChange = true; // SOFT OK -> HARD OK - - if (old_state == StateOK || old_stateType == StateTypeSoft) - SetStateType(StateTypeHard); // SOFT OK -> HARD OK or SOFT NON-OK -> HARD OK + SetStateType(StateTypeHard); // SOFT OK -> HARD OK attempt = 1; recovery = true; @@ -465,7 +458,6 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) if (old_attempt >= GetMaxCheckAttempts()) { SetStateType(StateTypeHard); attempt = 1; - hardChange = true; } else if (GetStateType() == StateTypeSoft || GetState() == StateOK) { SetStateType(StateTypeSoft); attempt = old_attempt + 1; @@ -508,6 +500,8 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) } } + bool hardChange = (GetStateType() == StateTypeHard && old_stateType == StateTypeSoft); + if (hardChange) SetLastHardStateChange(now); @@ -519,6 +513,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) bool in_downtime = IsInDowntime(); bool send_notification = hardChange && reachable && !in_downtime && !IsAcknowledged(); + if (old_state == StateOK && old_stateType == StateTypeSoft) + send_notification = false; /* Don't send notifications for SOFT-OK -> HARD-OK. */ + bool send_downtime_notification = m_LastInDowntime != in_downtime; m_LastInDowntime = in_downtime; Touch("last_in_downtime"); -- 2.40.0