mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 06:05:01 +02:00
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:
parent
a65f2d6b41
commit
daeab09334
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user