Merge pull request #6423 from Icinga/fix/scheduler-checks-too-often

Fix missing next check update causing the scheduler to execute checks too often
This commit is contained in:
Michael Friedrich 2018-07-02 17:08:47 +02:00 committed by GitHub
commit 418ba7602b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 2 deletions

View File

@ -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();

View File

@ -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();
{