diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp index c26db9de1..89426f8a1 100644 --- a/lib/checker/checkercomponent.cpp +++ b/lib/checker/checkercomponent.cpp @@ -174,6 +174,9 @@ void CheckerComponent::CheckThreadProc() m_IdleCheckables.insert(GetCheckableScheduleInfo(checkable)); lock.unlock(); + Log(LogDebug, "CheckerComponent") + << "Checks for checkable '" << checkable->GetName() << "' are disabled. Rescheduling check."; + checkable->UpdateNextCheck(); lock.lock(); @@ -181,7 +184,16 @@ void CheckerComponent::CheckThreadProc() continue; } - m_PendingCheckables.insert(GetCheckableScheduleInfo(checkable)); + + csi = GetCheckableScheduleInfo(checkable); + + Log(LogDebug, "CheckerComponent") + << "Scheduling info for checkable '" << checkable->GetName() << "' (" + << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", checkable->GetNextCheck()) << "): Object '" + << csi.Object->GetName() << "', Next Check: " + << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", csi.NextCheck) << "(" << csi.NextCheck << ")."; + + m_PendingCheckables.insert(csi); lock.unlock(); diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 719611aba..faf50694a 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -81,7 +81,14 @@ void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin) adj = std::min(0.5 + fmod(GetSchedulingOffset(), interval * 5) / 100.0, adj); - SetNextCheck(now - adj + interval, false, origin); + double nextCheck = now - adj + interval; + + Log(LogDebug, "Checkable") + << "Update checkable '" << GetName() << "' with check interval '" << GetCheckInterval() + << "' from last check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", GetLastCheck()) + << " (" << GetLastCheck() << ") to next check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", nextCheck) << "(" << nextCheck << ")."; + + SetNextCheck(nextCheck, false, origin); } bool Checkable::HasBeenChecked() const @@ -431,6 +438,12 @@ void Checkable::ExecuteCheck() double scheduled_start = GetNextCheck(); double before_check = Utility::GetTime(); + /* This calls SetNextCheck() which updates the CheckerComponent's idle/pending + * queues and ensures that checks are not fired multiple times. ProcessCheckResult() + * is called too late. See #6421. + */ + UpdateNextCheck(); + bool reachable = IsReachable(); {