If skipped due to time period, schedule next check on next transition

and not after yet another check interval. Otherwise checks done every 24h may get suppressed due to being re-scheduled outside time period every 24h.
This commit is contained in:
Alexander A. Klimov 2025-05-14 12:44:48 +02:00
parent a65f2d6b41
commit daeab09334

View File

@ -135,6 +135,7 @@ void CheckerComponent::CheckThreadProc()
bool forced = checkable->GetForceNextCheck(); bool forced = checkable->GetForceNextCheck();
bool check = true; bool check = true;
bool notifyNextCheck = false; bool notifyNextCheck = false;
double nextCheck = -1;
if (!forced) { if (!forced) {
if (!checkable->IsReachable(DependencyCheckExecution)) { if (!checkable->IsReachable(DependencyCheckExecution)) {
@ -162,13 +163,25 @@ void CheckerComponent::CheckThreadProc()
TimePeriod::Ptr tp = checkable->GetCheckPeriod(); TimePeriod::Ptr tp = checkable->GetCheckPeriod();
if (tp && !tp->IsInside(Utility::GetTime())) { if (tp) {
Log(LogNotice, "CheckerComponent") auto ts (Utility::GetTime());
<< "Skipping check for object '" << checkable->GetName() ObjectLock oLock (tp);
<< "': not in check period '" << tp->GetName() << "'";
check = false; if (!tp->IsInside(ts)) {
notifyNextCheck = true; 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)); m_IdleCheckables.insert(GetCheckableScheduleInfo(checkable));
lock.unlock(); lock.unlock();
Log(LogDebug, "CheckerComponent") if (nextCheck > 0) {
<< "Checks for checkable '" << checkable->GetName() << "' are disabled. Rescheduling check."; checkable->SetNextCheck(nextCheck);
} else {
Log(LogDebug, "CheckerComponent")
<< "Checks for checkable '" << checkable->GetName() << "' are disabled. Rescheduling check.";
checkable->UpdateNextCheck(); checkable->UpdateNextCheck();
}
if (notifyNextCheck) { if (notifyNextCheck) {
// Trigger update event for Icinga DB // Trigger update event for Icinga DB