Added log messages, fixed config.

This commit is contained in:
Gunnar Beutner 2012-06-14 16:31:38 +02:00
parent 0b9cd3423b
commit 146880c110
6 changed files with 32 additions and 3 deletions

View File

@ -87,6 +87,7 @@ int CheckerComponent::CheckTimerHandler(const TimerEventArgs& ea)
break;
CheckTask::Ptr ct = CheckTask::CreateTask(service);
Application::Log("Executing service check for '" + service.GetName() + "'");
CheckResult cr = ct->Execute();
m_Services.pop();

View File

@ -34,6 +34,11 @@ void DelegationComponent::Start(void)
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");
@ -95,6 +100,22 @@ int DelegationComponent::RevokeServiceResponseHandler(const NewResponseEventArgs
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.");

View File

@ -36,6 +36,7 @@ public:
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);
@ -43,6 +44,8 @@ private:
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);

View File

@ -4,7 +4,7 @@ local object application "icinga" {
cakey = "ca.crt",
node = "192.168.2.235",
service = 8888
service = 7777
}
local object component "configrpc" {
@ -19,7 +19,7 @@ local object component "discovery" {
local object endpoint "icinga-c3" {
node = "192.168.5.46",
service = 7777,
service = 9999,
roles = { "all" }
}

View File

@ -1,5 +1,5 @@
local object application "icinga" {
privkey = "icinga-c3".key",
privkey = "icinga-c3.key",
pubkey = "icinga-c3.crt",
cakey = "ca.crt",

View File

@ -17,6 +17,8 @@ CheckResult NagiosCheckTask::Execute(void) const
string command = m_Command + " 2>&1";
Application::Log("Nagios check command: " + command);
#ifdef _MSC_VER
fp = _popen(command.c_str(), "r");
#else /* _MSC_VER */
@ -37,6 +39,8 @@ CheckResult NagiosCheckTask::Execute(void) const
cr.Output = output.str();
Application::Log("Nagios plugin output: " + cr.Output);
int status, exitcode;
#ifdef _MSC_VER
status = _pclose(fp);