mirror of https://github.com/Icinga/icinga2.git
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)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
time(&now);
|
||||
|
||||
Timer::CollectionType::iterator prev, i;
|
||||
|
|
|
@ -121,7 +121,6 @@ void CheckerComponent::AdjustCheckTimer(void)
|
|||
|
||||
/* adjust next call time for the check timer */
|
||||
Service service = m_Services.top();
|
||||
|
||||
m_CheckTimer->Reschedule(service.GetNextCheck());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace icinga
|
|||
struct ServiceNextCheckLessComparer
|
||||
{
|
||||
public:
|
||||
bool operator()(const Service& a, const Service& b)
|
||||
bool operator()(Service& a, Service& b)
|
||||
{
|
||||
return a.GetNextCheck() > b.GetNextCheck();
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@ long Service::GetCheckInterval(void) const
|
|||
{
|
||||
long value = 300;
|
||||
GetConfigObject()->GetProperty("check_interval", &value);
|
||||
|
||||
if (value < 15)
|
||||
value = 15;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -68,10 +72,16 @@ void Service::SetNextCheck(time_t 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);
|
||||
|
||||
if (value == -1) {
|
||||
value = time(NULL) + rand() % GetCheckInterval();
|
||||
SetNextCheck(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
long GetRetryInterval(void) const;
|
||||
|
||||
void SetNextCheck(time_t nextCheck);
|
||||
time_t GetNextCheck(void) const;
|
||||
time_t GetNextCheck(void);
|
||||
void SetChecker(string checker);
|
||||
string GetChecker(void) const;
|
||||
void SetPendingCheck(bool pending);
|
||||
|
|
Loading…
Reference in New Issue