]> granicus.if.org Git - icinga2/commitdiff
Added log messages, fixed config.
authorGunnar Beutner <gunnar@beutner.name>
Thu, 14 Jun 2012 14:31:38 +0000 (16:31 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 14 Jun 2012 14:31:38 +0000 (16:31 +0200)
components/checker/checkercomponent.cpp
components/delegation/delegationcomponent.cpp
components/delegation/delegationcomponent.h
icinga-app/icinga2.conf
icinga-app/icinga3.conf
icinga/nagioschecktask.cpp

index 3b451efcaca7a11cebb43db726b61f0e62be4cd5..c65cb6ba7dfb0b8d3c7ef809e4559a0d067117c3 100644 (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();
index 4bb7cf2abcfbc05dadf9f435de004c41879f5550..cbce44c3fcbb9b43aa03f5132b0945a74ea0a8e8 100644 (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.");
index ade9183b3577fdc80ea0783ac65ad946fca9037a..b4221b28e01795a0e68b3c96cb6dea40f671ecdb 100644 (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);
 
index 88871008dd01c2bdbdcdd25469b6f9c3d5820304..979764daf7d5891754659c1718feecd60381064a 100644 (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" }
 }
index 0611a73afb487b5227cabdc047f0c2a44367fded..26042a03fc5f6352f0eb12305d8d3002b83b817a 100644 (file)
@@ -1,5 +1,5 @@
 local object application "icinga" {
-       privkey = "icinga-c3".key",
+       privkey = "icinga-c3.key",
        pubkey = "icinga-c3.crt",
        cakey = "ca.crt",
 
index dc2f3a08aac1357850278049a115bb4bc43b0d16..f6adac5b125593e60f28d08d24bf765318a429c1 100644 (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);