m_Services.pop();
-// Application::Log(LogInformation, "checker", "Executing service check for '" + service.GetName() + "'");
+ Application::Log(LogDebug, "checker", "Executing service check for '" + service.GetName() + "'");
CheckTask::Ptr task = CheckTask::CreateTask(service);
task->Enqueue();
stringstream msgbuf;
msgbuf << "CheckTimerHandler: created " << tasks << " tasks";
- Application::Log(LogDebug, "checker", msgbuf.str());
+ Application::Log(LogInformation, "checker", msgbuf.str());
}
void CheckerComponent::ResultTimerHandler(void)
time_t now;
time(&now);
- long min_latency = -1, max_latency = 0, avg_latency = 0, results = 0;
+ long min_latency = -1, max_latency = 0, avg_latency = 0, results = 0, failed = 0;
vector<CheckTask::Ptr> finishedTasks = CheckTask::GetFinishedTasks();
Service service = task->GetService();
CheckResult result = task->GetResult();
-// Application::Log(LogInformation, "checker", "Got result! Plugin output: " + result.Output);
+ Application::Log(LogDebug, "checker", "Got result for service '" + service.GetName() + "'");
long latency = result.EndTime - result.StartTime;
avg_latency += latency;
results++;
+ if (result.State != StateOK)
+ failed++;
+
service.SetNextCheck(now + service.GetCheckInterval());
m_Services.push(service);
}
stringstream msgbuf;
- msgbuf << "ResultTimerHandler: " << results << " results; latency: avg=" << avg_latency / (results ? results : 1) << ", min=" << min_latency << ", max: " << max_latency;
- Application::Log(LogDebug, "checker", msgbuf.str());
+ msgbuf << "ResultTimerHandler: " << results << " results (" << failed << " failed); latency: avg=" << avg_latency / (results ? results : 1) << ", min=" << min_latency << ", max: " << max_latency;
+ Application::Log(LogInformation, "checker", msgbuf.str());
}
void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
Service service(object);
m_Services.push(service);
- Application::Log(LogInformation, "checker", "Accepted delegation for service '" + service.GetName() + "'");
+ Application::Log(LogDebug, "checker", "Accepted delegation for service '" + service.GetName() + "'");
/* force a service check */
m_CheckTimer->Reschedule(0);
for (it = services.begin(); it != services.end(); it++)
m_Services.push(*it);
- Application::Log(LogInformation, "checker", "Revoked delegation for service '" + name + "'");
+ Application::Log(LogDebug, "checker", "Revoked delegation for service '" + name + "'");
string id;
if (request.GetID(&id)) {
void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
- Application::Log(LogInformation, "checker", "Clearing service delegations.");
+ Application::Log(LogDebug, "checker", "Clearing service delegations.");
m_Services = ServiceQueue();
string id;
params.SetProperty("service", service.GetConfigObject()->GetProperties());
request.SetParams(params);
- Application::Log(LogInformation, "delegation", "Trying to delegate service '" + service.GetName() + "'");
+ Application::Log(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");
GetEndpointManager()->SendAPIMessage(m_DelegationEndpoint, request,
boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _2, _5));
void DelegationComponent::AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut)
{
if (timedOut) {
- Application::Log(LogInformation, "delegation", "Service delegation for service '" + service.GetName() + "' timed out.");
+ Application::Log(LogDebug, "delegation", "Service delegation for service '" + service.GetName() + "' timed out.");
} else {
service.SetChecker(sender->GetIdentity());
- Application::Log(LogInformation, "delegation", "Service delegation for service '" + service.GetName() + "' was successful.");
+ Application::Log(LogDebug, "delegation", "Service delegation for service '" + service.GetName() + "' was successful.");
}
}
void DelegationComponent::DelegationTimerHandler(void)
{
ConfigObject::Set::Iterator it;
+ long delegated = 0;
for (it = m_AllServices->Begin(); it != m_AllServices->End(); it++) {
Service service = *it;
continue;
AssignService(service);
+ delegated++;
}
- m_DelegationTimer->Stop();
+ stringstream msgbuf;
+ msgbuf << "Delegated " << delegated << " services";
+ Application::Log(LogInformation, "delegation", msgbuf.str());
}
EXPORT_COMPONENT(delegation, DelegationComponent);