mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-20 12:14:44 +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)
|
void Service::UpdateNextCheck(void)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now, previous, next, interval;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
|
previous = GetNextCheck();
|
||||||
|
|
||||||
if (GetStateType() == StateTypeSoft)
|
if (GetStateType() == StateTypeSoft)
|
||||||
SetNextCheck(now + GetRetryInterval());
|
interval = GetRetryInterval();
|
||||||
else
|
else
|
||||||
SetNextCheck(now + GetCheckInterval());
|
interval = GetCheckInterval();
|
||||||
|
|
||||||
|
next = now + ((now - previous) / interval + 1) * interval;
|
||||||
|
SetNextCheck(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::SetChecker(const string& checker)
|
void Service::SetChecker(const string& checker)
|
||||||
|
@ -104,6 +104,9 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
|
|||||||
{
|
{
|
||||||
service.RemoveTag("current_task");
|
service.RemoveTag("current_task");
|
||||||
|
|
||||||
|
/* figure out when the next check is for this service */
|
||||||
|
service.UpdateNextCheck();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Variant vresult = task->GetResult();
|
Variant vresult = task->GetResult();
|
||||||
|
|
||||||
@ -135,14 +138,13 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
|
|||||||
Logger::Write(LogWarning, "checker", msgbuf.str());
|
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
|
/* 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
|
* 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. */
|
* service to the services list because it's already there. */
|
||||||
if (m_PendingServices.find(service.GetConfigObject()) != m_PendingServices.end()) {
|
set<ConfigObject::Ptr>::iterator it;
|
||||||
m_PendingServices.erase(service.GetConfigObject());
|
it = m_PendingServices.find(service.GetConfigObject());
|
||||||
|
if (it != m_PendingServices.end()) {
|
||||||
|
m_PendingServices.erase(it);
|
||||||
m_Services.push(service);
|
m_Services.push(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user