mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-26 11:08:51 +02:00
checker: make result timer interval configurable for testing
This commit is contained in:
parent
2a75c7711a
commit
ab8621f6be
@ -71,7 +71,7 @@ void CheckerComponent::Start(bool runtimeCreated)
|
||||
m_Thread = std::thread([this]() { CheckThreadProc(); });
|
||||
|
||||
m_ResultTimer = Timer::Create();
|
||||
m_ResultTimer->SetInterval(5);
|
||||
m_ResultTimer->SetInterval(m_ResultTimerInterval);
|
||||
m_ResultTimer->OnTimerExpired.connect([this](const Timer * const&) { ResultTimerHandler(); });
|
||||
m_ResultTimer->Start();
|
||||
}
|
||||
@ -376,3 +376,18 @@ unsigned long CheckerComponent::GetPendingCheckables()
|
||||
|
||||
return m_PendingCheckables.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the interval in seconds for the result timer.
|
||||
*
|
||||
* The result timer periodically logs the number of pending and idle checkables
|
||||
* as well as the checks per second rate. The default interval is 5 seconds.
|
||||
*
|
||||
* Note, this method must be called before the component is started to have an effect on the timer.
|
||||
*
|
||||
* @param interval Interval in seconds for the result timer.
|
||||
*/
|
||||
void CheckerComponent::SetResultTimerInterval(double interval)
|
||||
{
|
||||
m_ResultTimerInterval = interval;
|
||||
}
|
||||
|
@ -73,12 +73,16 @@ public:
|
||||
unsigned long GetIdleCheckables();
|
||||
unsigned long GetPendingCheckables();
|
||||
|
||||
void SetResultTimerInterval(double interval);
|
||||
|
||||
private:
|
||||
std::mutex m_Mutex;
|
||||
std::condition_variable m_CV;
|
||||
bool m_Stopped{false};
|
||||
std::thread m_Thread;
|
||||
|
||||
double m_ResultTimerInterval{5.0}; // Interval in seconds for the result timer.
|
||||
|
||||
CheckableSet m_IdleCheckables;
|
||||
CheckableSet m_PendingCheckables;
|
||||
|
||||
@ -90,13 +94,9 @@ private:
|
||||
|
||||
void ExecuteCheckHelper(const Checkable::Ptr& checkable);
|
||||
|
||||
void AdjustCheckTimer();
|
||||
|
||||
void ObjectHandler(const ConfigObject::Ptr& object);
|
||||
void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck = -1);
|
||||
|
||||
void RescheduleCheckTimer();
|
||||
|
||||
static CheckableScheduleInfo GetCheckableScheduleInfo(const Checkable::Ptr& checkable);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user