mirror of https://github.com/Icinga/icinga2.git
Bugfixes.
This commit is contained in:
parent
6648af73ae
commit
74bae58f21
|
@ -151,5 +151,7 @@ void Timer::Stop(void)
|
|||
void Timer::Reschedule(time_t next)
|
||||
{
|
||||
m_Next = next;
|
||||
RescheduleTimers();
|
||||
|
||||
if (next < NextCall)
|
||||
NextCall = next;
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ void CheckerComponent::CheckTimerHandler(void)
|
|||
time_t now;
|
||||
time(&now);
|
||||
|
||||
if (m_Services.size() == 0)
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
if (m_Services.size() == 0)
|
||||
break;
|
||||
|
||||
Service service = m_Services.top();
|
||||
|
||||
if (service.GetNextCheck() > now || service.HasPendingCheck())
|
||||
|
@ -83,7 +83,6 @@ void CheckerComponent::CheckTimerHandler(void)
|
|||
m_PendingTasks.push_back(task);
|
||||
|
||||
service.SetNextCheck(now + service.GetCheckInterval());
|
||||
m_Services.push(service);
|
||||
}
|
||||
|
||||
AdjustCheckTimer();
|
||||
|
@ -101,10 +100,13 @@ void CheckerComponent::ResultTimerHandler(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
task->GetService().SetPendingCheck(false);
|
||||
Service service = task->GetService();
|
||||
service.SetPendingCheck(false);
|
||||
|
||||
CheckResult result = task->GetResult();
|
||||
Application::Log(LogInformation, "checker", "Got result! Plugin output: " + result.Output);
|
||||
|
||||
m_Services.push(service);
|
||||
}
|
||||
|
||||
m_PendingTasks = unfinishedTasks;
|
||||
|
@ -176,6 +178,9 @@ void CheckerComponent::RevokeServiceRequestHandler(const Endpoint::Ptr& sender,
|
|||
if (service.GetName() == name)
|
||||
continue;
|
||||
|
||||
if (service.HasPendingCheck()) // TODO: remember services that should be removed once their pending check is done
|
||||
throw runtime_error("not yet implemented");
|
||||
|
||||
services.push_back(service);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,14 +23,11 @@
|
|||
namespace icinga
|
||||
{
|
||||
|
||||
struct ServiceCheckPriorityLessComparer
|
||||
struct ServiceNextCheckLessComparer
|
||||
{
|
||||
public:
|
||||
bool operator()(const Service& a, const Service& b)
|
||||
{
|
||||
if (a.HasPendingCheck() && !b.HasPendingCheck())
|
||||
return true;
|
||||
|
||||
return a.GetNextCheck() > b.GetNextCheck();
|
||||
}
|
||||
};
|
||||
|
@ -44,17 +41,20 @@ public:
|
|||
typedef shared_ptr<CheckerComponent> Ptr;
|
||||
typedef weak_ptr<CheckerComponent> WeakPtr;
|
||||
|
||||
typedef priority_queue<Service, vector<Service>, ServiceCheckPriorityLessComparer> ServiceQueue;
|
||||
typedef priority_queue<Service, vector<Service>, ServiceNextCheckLessComparer> ServiceQueue;
|
||||
|
||||
virtual string GetName(void) const;
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
private:
|
||||
ServiceQueue m_Services;
|
||||
Timer::Ptr m_CheckTimer;
|
||||
VirtualEndpoint::Ptr m_CheckerEndpoint;
|
||||
|
||||
ServiceQueue m_Services;
|
||||
set<Service> m_PendingServices;
|
||||
|
||||
Timer::Ptr m_CheckTimer;
|
||||
|
||||
Timer::Ptr m_ResultTimer;
|
||||
vector<CheckTask::Ptr> m_PendingTasks;
|
||||
|
||||
|
|
Loading…
Reference in New Issue