diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp index 06ebb7bba..942a6fa9e 100644 --- a/lib/checker/checkercomponent.cpp +++ b/lib/checker/checkercomponent.cpp @@ -135,6 +135,7 @@ void CheckerComponent::CheckThreadProc() bool forced = checkable->GetForceNextCheck(); bool check = true; bool notifyNextCheck = false; + double nextCheck = -1; if (!forced) { if (!checkable->IsReachable(DependencyCheckExecution)) { @@ -162,13 +163,25 @@ void CheckerComponent::CheckThreadProc() TimePeriod::Ptr tp = checkable->GetCheckPeriod(); - if (tp && !tp->IsInside(Utility::GetTime())) { - Log(LogNotice, "CheckerComponent") - << "Skipping check for object '" << checkable->GetName() - << "': not in check period '" << tp->GetName() << "'"; + if (tp) { + auto ts (Utility::GetTime()); + ObjectLock oLock (tp); - check = false; - notifyNextCheck = true; + if (!tp->IsInside(ts)) { + nextCheck = tp->FindNextTransition(ts); + + if (nextCheck <= 0) { + nextCheck = tp->GetValidEnd(); + } + + Log(LogNotice, "CheckerComponent") + << "Skipping check for object '" << checkable->GetName() + << "', as not in check period '" << tp->GetName() << "', until " + << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", nextCheck); + + check = false; + notifyNextCheck = true; + } } } @@ -177,10 +190,14 @@ void CheckerComponent::CheckThreadProc() m_IdleCheckables.insert(GetCheckableScheduleInfo(checkable)); lock.unlock(); - Log(LogDebug, "CheckerComponent") - << "Checks for checkable '" << checkable->GetName() << "' are disabled. Rescheduling check."; + if (nextCheck > 0) { + checkable->SetNextCheck(nextCheck); + } else { + Log(LogDebug, "CheckerComponent") + << "Checks for checkable '" << checkable->GetName() << "' are disabled. Rescheduling check."; - checkable->UpdateNextCheck(); + checkable->UpdateNextCheck(); + } if (notifyNextCheck) { // Trigger update event for Icinga DB