From 601c54e44e9c6651ba843d823fd683d7a543e320 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 2 Jul 2018 16:17:33 +0200 Subject: [PATCH] Add more debug logging for check scheduling --- lib/checker/checkercomponent.cpp | 14 +++++++++++++- lib/icinga/checkable-check.cpp | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) 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..619e3c0ee 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