mirror of https://github.com/Icinga/icinga2.git
Added log messages, fixed config.
This commit is contained in:
parent
0b9cd3423b
commit
146880c110
|
@ -87,6 +87,7 @@ int CheckerComponent::CheckTimerHandler(const TimerEventArgs& ea)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CheckTask::Ptr ct = CheckTask::CreateTask(service);
|
CheckTask::Ptr ct = CheckTask::CreateTask(service);
|
||||||
|
Application::Log("Executing service check for '" + service.GetName() + "'");
|
||||||
CheckResult cr = ct->Execute();
|
CheckResult cr = ct->Execute();
|
||||||
|
|
||||||
m_Services.pop();
|
m_Services.pop();
|
||||||
|
|
|
@ -34,6 +34,11 @@ void DelegationComponent::Start(void)
|
||||||
m_AllServices->OnObjectRemoved.connect(bind(&DelegationComponent::RemovedServiceHandler, this, _1));
|
m_AllServices->OnObjectRemoved.connect(bind(&DelegationComponent::RemovedServiceHandler, this, _1));
|
||||||
m_AllServices->Start();
|
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 = make_shared<VirtualEndpoint>();
|
||||||
m_DelegationEndpoint->RegisterPublication("checker::AssignService");
|
m_DelegationEndpoint->RegisterPublication("checker::AssignService");
|
||||||
m_DelegationEndpoint->RegisterPublication("checker::RevokeService");
|
m_DelegationEndpoint->RegisterPublication("checker::RevokeService");
|
||||||
|
@ -95,6 +100,22 @@ int DelegationComponent::RevokeServiceResponseHandler(const NewResponseEventArgs
|
||||||
return 0;
|
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)
|
int DelegationComponent::TestResponseHandler(const NewResponseEventArgs& ea)
|
||||||
{
|
{
|
||||||
Application::Log("Response handler called.");
|
Application::Log("Response handler called.");
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
private:
|
private:
|
||||||
VirtualEndpoint::Ptr m_DelegationEndpoint;
|
VirtualEndpoint::Ptr m_DelegationEndpoint;
|
||||||
ConfigObject::Set::Ptr m_AllServices;
|
ConfigObject::Set::Ptr m_AllServices;
|
||||||
|
Timer::Ptr m_DelegationTimer;
|
||||||
|
|
||||||
int NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
|
int NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
|
||||||
int RemovedServiceHandler(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 AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea);
|
||||||
int RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
|
int RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
|
||||||
|
|
||||||
|
int DelegationTimerHandler(const TimerEventArgs& ea);
|
||||||
|
|
||||||
void AssignService(const ConfigObject::Ptr& service);
|
void AssignService(const ConfigObject::Ptr& service);
|
||||||
void RevokeService(const ConfigObject::Ptr& service);
|
void RevokeService(const ConfigObject::Ptr& service);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ local object application "icinga" {
|
||||||
|
|
||||||
cakey = "ca.crt",
|
cakey = "ca.crt",
|
||||||
node = "192.168.2.235",
|
node = "192.168.2.235",
|
||||||
service = 8888
|
service = 7777
|
||||||
}
|
}
|
||||||
|
|
||||||
local object component "configrpc" {
|
local object component "configrpc" {
|
||||||
|
@ -19,7 +19,7 @@ local object component "discovery" {
|
||||||
|
|
||||||
local object endpoint "icinga-c3" {
|
local object endpoint "icinga-c3" {
|
||||||
node = "192.168.5.46",
|
node = "192.168.5.46",
|
||||||
service = 7777,
|
service = 9999,
|
||||||
|
|
||||||
roles = { "all" }
|
roles = { "all" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local object application "icinga" {
|
local object application "icinga" {
|
||||||
privkey = "icinga-c3".key",
|
privkey = "icinga-c3.key",
|
||||||
pubkey = "icinga-c3.crt",
|
pubkey = "icinga-c3.crt",
|
||||||
cakey = "ca.crt",
|
cakey = "ca.crt",
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ CheckResult NagiosCheckTask::Execute(void) const
|
||||||
|
|
||||||
string command = m_Command + " 2>&1";
|
string command = m_Command + " 2>&1";
|
||||||
|
|
||||||
|
Application::Log("Nagios check command: " + command);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
fp = _popen(command.c_str(), "r");
|
fp = _popen(command.c_str(), "r");
|
||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
|
@ -37,6 +39,8 @@ CheckResult NagiosCheckTask::Execute(void) const
|
||||||
|
|
||||||
cr.Output = output.str();
|
cr.Output = output.str();
|
||||||
|
|
||||||
|
Application::Log("Nagios plugin output: " + cr.Output);
|
||||||
|
|
||||||
int status, exitcode;
|
int status, exitcode;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
status = _pclose(fp);
|
status = _pclose(fp);
|
||||||
|
|
Loading…
Reference in New Issue