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())
m_PendingTasks.push_back(task);
service.SetNextCheck(now + service.GetCheckInterval());
- m_Services.push(service);
}
AdjustCheckTimer();
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;
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);
}
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();
}
};
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:
+ VirtualEndpoint::Ptr m_CheckerEndpoint;
+
ServiceQueue m_Services;
+ set<Service> m_PendingServices;
+
Timer::Ptr m_CheckTimer;
- VirtualEndpoint::Ptr m_CheckerEndpoint;
Timer::Ptr m_ResultTimer;
vector<CheckTask::Ptr> m_PendingTasks;