break;
CheckTask::Ptr ct = CheckTask::CreateTask(service);
+ Application::Log("Executing service check for '" + service.GetName() + "'");
CheckResult cr = ct->Execute();
m_Services.pop();
m_AllServices->OnObjectRemoved.connect(bind(&DelegationComponent::RemovedServiceHandler, this, _1));
m_AllServices->Start();
+ m_DelegationTimer = make_shared<Timer>();
+ m_DelegationTimer->SetInterval(30);
+ m_DelegationTimer->OnTimerExpired.connect(bind(&DelegationComponent::DelegationTimerHandler, this, _1));
+ m_DelegationTimer->Start();
+
m_DelegationEndpoint = make_shared<VirtualEndpoint>();
m_DelegationEndpoint->RegisterPublication("checker::AssignService");
m_DelegationEndpoint->RegisterPublication("checker::RevokeService");
return 0;
}
+int DelegationComponent::DelegationTimerHandler(const TimerEventArgs& ea)
+{
+ ConfigObject::Set::Iterator it;
+ for (it = m_AllServices->Begin(); it != m_AllServices->End(); it++) {
+ ConfigObject::Ptr object = *it;
+
+ string checker;
+ if (object->GetTag("checker", &checker) && GetEndpointManager()->GetEndpointByIdentity(checker))
+ continue;
+
+ AssignService(object);
+ }
+
+ return 0;
+}
+
int DelegationComponent::TestResponseHandler(const NewResponseEventArgs& ea)
{
Application::Log("Response handler called.");
private:
VirtualEndpoint::Ptr m_DelegationEndpoint;
ConfigObject::Set::Ptr m_AllServices;
+ Timer::Ptr m_DelegationTimer;
int NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
int RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
int AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea);
int RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
+ int DelegationTimerHandler(const TimerEventArgs& ea);
+
void AssignService(const ConfigObject::Ptr& service);
void RevokeService(const ConfigObject::Ptr& service);
cakey = "ca.crt",
node = "192.168.2.235",
- service = 8888
+ service = 7777
}
local object component "configrpc" {
local object endpoint "icinga-c3" {
node = "192.168.5.46",
- service = 7777,
+ service = 9999,
roles = { "all" }
}
local object application "icinga" {
- privkey = "icinga-c3".key",
+ privkey = "icinga-c3.key",
pubkey = "icinga-c3.crt",
cakey = "ca.crt",
string command = m_Command + " 2>&1";
+ Application::Log("Nagios check command: " + command);
+
#ifdef _MSC_VER
fp = _popen(command.c_str(), "r");
#else /* _MSC_VER */
cr.Output = output.str();
+ Application::Log("Nagios plugin output: " + cr.Output);
+
int status, exitcode;
#ifdef _MSC_VER
status = _pclose(fp);