Use UpdateNextCheck() for determining the retry_interval in ProcessCheckResult()

This patch also moves the next check updates for passive
check results into ProcessCheckResult(). That way the
next check status updates for DB IDO work in a sane way
again.

refs #11336
This commit is contained in:
Michael Friedrich 2016-03-15 13:02:38 +01:00 committed by Gunnar Beutner
parent 122256bb91
commit 8668eb65b5
4 changed files with 15 additions and 25 deletions

View File

@ -110,11 +110,6 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
checkable->ProcessCheckResult(cr);
/* Reschedule the next check. The side effect of this is that for as long
* as we receive passive results for a service we won't execute any
* active checks. */
checkable->SetNextCheck(Utility::GetTime() + checkable->GetCheckInterval());
return ApiActions::CreateResult(200, "Successfully processed check result for object '" + checkable->GetName() + "'.");
}

View File

@ -61,7 +61,7 @@ long Checkable::GetSchedulingOffset(void)
return m_SchedulingOffset;
}
void Checkable::UpdateNextCheck(void)
void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
{
double interval;
@ -76,7 +76,7 @@ void Checkable::UpdateNextCheck(void)
if (interval > 1)
adj = fmod(now * 100 + GetSchedulingOffset(), interval * 100) / 100.0;
SetNextCheck(now - adj + interval);
SetNextCheck(now - adj + interval, false, origin);
}
bool Checkable::HasBeenChecked(void) const
@ -198,13 +198,6 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
} else if (IsStateOK(old_state)) {
SetStateType(StateTypeSoft);
attempt = 1; // OK -> NOT-OK transition, reset the counter
/* If there was a OK -> NOT-OK state change for actively scheduled checks,
* update the next check time using the retry_interval.
* Important: Add the cluster message origin.
*/
if (cr->GetActive())
SetNextCheck(Utility::GetTime() + GetRetryInterval(), false, origin);
} else {
attempt = old_attempt;
}
@ -329,6 +322,18 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
is_flapping = IsFlapping();
if (cr->GetActive()) {
/* If there was a OK -> NOT-OK state change for actively scheduled checks,
* update the next check time using the retry_interval.
* Important: Add the cluster message origin. */
UpdateNextCheck(origin);
} else {
/* Reschedule the next check for passive check results. The side effect of
* this is that for as long as we receive passive results for a service we
* won't execute any active checks. */
SetNextCheck(Utility::GetTime() + GetCheckInterval(), false, origin);
}
olock.Unlock();
// Log(LogDebug, "Checkable")

View File

@ -89,7 +89,7 @@ public:
long GetSchedulingOffset(void);
void SetSchedulingOffset(long offset);
void UpdateNextCheck(void);
void UpdateNextCheck(const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
bool HasBeenChecked(void) const;
virtual bool IsStateOK(ServiceState state) = 0;

View File

@ -329,11 +329,6 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
<< "Processing passive check result for host '" << arguments[0] << "'";
host->ProcessCheckResult(result);
/* Reschedule the next check. The side effect of this is that for as long
* as we receive passive results for a service we won't execute any
* active checks. */
host->SetNextCheck(Utility::GetTime() + host->GetCheckInterval());
}
void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std::vector<String>& arguments)
@ -366,11 +361,6 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
<< "Processing passive check result for service '" << arguments[1] << "'";
service->ProcessCheckResult(result);
/* Reschedule the next check. The side effect of this is that for as long
* as we receive passive results for a service we won't execute any
* active checks. */
service->SetNextCheck(Utility::GetTime() + service->GetCheckInterval());
}
void ExternalCommandProcessor::ScheduleHostCheck(double, const std::vector<String>& arguments)