mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
Evenly distribute checks in the check interval.
This commit is contained in:
parent
30af9494d8
commit
bd1e8b2395
@ -71,7 +71,6 @@ void Timer::RescheduleTimers(void)
|
|||||||
void Timer::CallExpiredTimers(void)
|
void Timer::CallExpiredTimers(void)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
|
|
||||||
Timer::CollectionType::iterator prev, i;
|
Timer::CollectionType::iterator prev, i;
|
||||||
|
@ -121,7 +121,6 @@ void CheckerComponent::AdjustCheckTimer(void)
|
|||||||
|
|
||||||
/* adjust next call time for the check timer */
|
/* adjust next call time for the check timer */
|
||||||
Service service = m_Services.top();
|
Service service = m_Services.top();
|
||||||
|
|
||||||
m_CheckTimer->Reschedule(service.GetNextCheck());
|
m_CheckTimer->Reschedule(service.GetNextCheck());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace icinga
|
|||||||
struct ServiceNextCheckLessComparer
|
struct ServiceNextCheckLessComparer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool operator()(const Service& a, const Service& b)
|
bool operator()(Service& a, Service& b)
|
||||||
{
|
{
|
||||||
return a.GetNextCheck() > b.GetNextCheck();
|
return a.GetNextCheck() > b.GetNextCheck();
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,10 @@ long Service::GetCheckInterval(void) const
|
|||||||
{
|
{
|
||||||
long value = 300;
|
long value = 300;
|
||||||
GetConfigObject()->GetProperty("check_interval", &value);
|
GetConfigObject()->GetProperty("check_interval", &value);
|
||||||
|
|
||||||
|
if (value < 15)
|
||||||
|
value = 15;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +72,16 @@ void Service::SetNextCheck(time_t nextCheck)
|
|||||||
GetConfigObject()->SetTag("next_check", static_cast<long>(nextCheck));
|
GetConfigObject()->SetTag("next_check", static_cast<long>(nextCheck));
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t Service::GetNextCheck(void) const
|
time_t Service::GetNextCheck(void)
|
||||||
{
|
{
|
||||||
long value = 0;
|
long value = -1;
|
||||||
GetConfigObject()->GetTag("next_check", &value);
|
GetConfigObject()->GetTag("next_check", &value);
|
||||||
|
|
||||||
|
if (value == -1) {
|
||||||
|
value = time(NULL) + rand() % GetCheckInterval();
|
||||||
|
SetNextCheck(value);
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
long GetRetryInterval(void) const;
|
long GetRetryInterval(void) const;
|
||||||
|
|
||||||
void SetNextCheck(time_t nextCheck);
|
void SetNextCheck(time_t nextCheck);
|
||||||
time_t GetNextCheck(void) const;
|
time_t GetNextCheck(void);
|
||||||
void SetChecker(string checker);
|
void SetChecker(string checker);
|
||||||
string GetChecker(void) const;
|
string GetChecker(void) const;
|
||||||
void SetPendingCheck(bool pending);
|
void SetPendingCheck(bool pending);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user