diff --git a/lib/icinga/apiactions.cpp b/lib/icinga/apiactions.cpp index a67121b53..37f22cc43 100644 --- a/lib/icinga/apiactions.cpp +++ b/lib/icinga/apiactions.cpp @@ -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() + "'."); } diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 79c690f06..c5f3b605b 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -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") diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 849806420..a576f5768 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -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; diff --git a/lib/icinga/externalcommandprocessor.cpp b/lib/icinga/externalcommandprocessor.cpp index a98127e1e..09eeac2a9 100644 --- a/lib/icinga/externalcommandprocessor.cpp +++ b/lib/icinga/externalcommandprocessor.cpp @@ -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& 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& arguments)