Use retry_interval on first OK -> NOT-OK state change

Only valid for active check results. The API actions were
missing that marker similar to the external command processor.

The initial OK -> NOT-OK transition should use the retry_interval
but nothing else.

fixes #11336
This commit is contained in:
Michael Friedrich 2016-03-11 10:30:50 +01:00
parent 5b6a6f86b1
commit 7fb8bcd933
3 changed files with 17 additions and 2 deletions

View File

@ -104,6 +104,10 @@ Dictionary::Ptr ApiActions::ProcessCheckResult(const ConfigObject::Ptr& object,
cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source")); cr->SetCheckSource(HttpUtility::GetLastParameter(params, "check_source"));
cr->SetPerformanceData(params->Get("performance_data")); cr->SetPerformanceData(params->Get("performance_data"));
cr->SetCommand(params->Get("check_command")); cr->SetCommand(params->Get("check_command"));
/* Mark this check result as passive. */
cr->SetActive(false);
checkable->ProcessCheckResult(cr); checkable->ProcessCheckResult(cr);
/* Reschedule the next check. The side effect of this is that for as long /* Reschedule the next check. The side effect of this is that for as long

View File

@ -204,10 +204,17 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
SetStateType(StateTypeHard); SetStateType(StateTypeHard);
} else if (old_stateType == StateTypeSoft && !StateIsOK(checkableType, old_state)) { } else if (old_stateType == StateTypeSoft && !StateIsOK(checkableType, old_state)) {
SetStateType(StateTypeSoft); SetStateType(StateTypeSoft);
attempt = old_attempt + 1; //NOT-OK -> NOT-OK counter attempt = old_attempt + 1; // NOT-OK -> NOT-OK counter
} else if (StateIsOK(checkableType, old_state)) { } else if (StateIsOK(checkableType, old_state)) {
SetStateType(StateTypeSoft); SetStateType(StateTypeSoft);
attempt = 1; //OK -> NOT-OK transition, reset the counter 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 { } else {
attempt = old_attempt; attempt = old_attempt;
} }

View File

@ -359,6 +359,8 @@ void ExternalCommandProcessor::ProcessHostCheckResult(double time, const std::ve
result->SetScheduleEnd(time); result->SetScheduleEnd(time);
result->SetExecutionStart(time); result->SetExecutionStart(time);
result->SetExecutionEnd(time); result->SetExecutionEnd(time);
/* Mark this check result as passive. */
result->SetActive(false); result->SetActive(false);
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")
@ -394,6 +396,8 @@ void ExternalCommandProcessor::ProcessServiceCheckResult(double time, const std:
result->SetScheduleEnd(time); result->SetScheduleEnd(time);
result->SetExecutionStart(time); result->SetExecutionStart(time);
result->SetExecutionEnd(time); result->SetExecutionEnd(time);
/* Mark this check result as passive. */
result->SetActive(false); result->SetActive(false);
Log(LogNotice, "ExternalCommandProcessor") Log(LogNotice, "ExternalCommandProcessor")