mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Try to more uniformly distribute checks in their check interval.
This commit is contained in:
parent
0016c7b79d
commit
f6c95efa45
@ -190,13 +190,18 @@ time_t Service::GetNextCheck(void)
|
||||
|
||||
void Service::UpdateNextCheck(void)
|
||||
{
|
||||
time_t now;
|
||||
time_t now, previous, next, interval;
|
||||
|
||||
time(&now);
|
||||
previous = GetNextCheck();
|
||||
|
||||
if (GetStateType() == StateTypeSoft)
|
||||
SetNextCheck(now + GetRetryInterval());
|
||||
interval = GetRetryInterval();
|
||||
else
|
||||
SetNextCheck(now + GetCheckInterval());
|
||||
interval = GetCheckInterval();
|
||||
|
||||
next = now + ((now - previous) / interval + 1) * interval;
|
||||
SetNextCheck(next);
|
||||
}
|
||||
|
||||
void Service::SetChecker(const string& checker)
|
||||
|
@ -104,6 +104,9 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
|
||||
{
|
||||
service.RemoveTag("current_task");
|
||||
|
||||
/* figure out when the next check is for this service */
|
||||
service.UpdateNextCheck();
|
||||
|
||||
try {
|
||||
Variant vresult = task->GetResult();
|
||||
|
||||
@ -135,14 +138,13 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
|
||||
Logger::Write(LogWarning, "checker", msgbuf.str());
|
||||
}
|
||||
|
||||
/* figure out when the next check is for this service */
|
||||
service.UpdateNextCheck();
|
||||
|
||||
/* remove the service from the list of pending services; if it's not in the
|
||||
* list this was a manual (i.e. forced) check and we must not re-add the
|
||||
* service to the services list because it's already there. */
|
||||
if (m_PendingServices.find(service.GetConfigObject()) != m_PendingServices.end()) {
|
||||
m_PendingServices.erase(service.GetConfigObject());
|
||||
set<ConfigObject::Ptr>::iterator it;
|
||||
it = m_PendingServices.find(service.GetConfigObject());
|
||||
if (it != m_PendingServices.end()) {
|
||||
m_PendingServices.erase(it);
|
||||
m_Services.push(service);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user