]> granicus.if.org Git - icinga2/commitdiff
Add debug log entries for dependencies.
authorMichael Friedrich <Michael.Friedrich@netways.de>
Sat, 3 May 2014 19:02:19 +0000 (21:02 +0200)
committerMichael Friedrich <Michael.Friedrich@netways.de>
Sat, 3 May 2014 19:04:56 +0000 (21:04 +0200)
Refs #5872

components/compat/statusdatawriter.cpp
lib/db_ido/hostdbobject.cpp
lib/db_ido/servicedbobject.cpp
lib/icinga/dependency.cpp
test/config/5872.conf

index 556e00e458e489348811e5fea96595385c41aa4e..2b2f0320cb84d33ed74c13df54bbc3391cd276fa 100644 (file)
@@ -696,8 +696,10 @@ void StatusDataWriter::UpdateObjectsCache(void)
        BOOST_FOREACH(const Dependency::Ptr& dep, DynamicType::GetObjects<Dependency>()) {
                Checkable::Ptr parent = dep->GetParent();
 
-               if (!parent)
+               if (!parent) {
+                       Log(LogDebug, "compat", "Missing parent for dependency '" + dep->GetName() + "'.");
                        continue;
+               }
 
                Host::Ptr parent_host;
                Service::Ptr parent_service;
@@ -705,8 +707,10 @@ void StatusDataWriter::UpdateObjectsCache(void)
 
                Checkable::Ptr child = dep->GetChild();
 
-               if (!child)
+               if (!child) {
                        continue;
+                       Log(LogDebug, "compat", "Missing child for dependency '" + dep->GetName() + "'.");
+               }
 
                Host::Ptr child_host;
                Service::Ptr child_service;
index 356b16af7c640ef580b51d5933e3c059eb5fcf30..9b88bc6b5daa4a606829899240209571c3d141a3 100644 (file)
@@ -204,8 +204,10 @@ void HostDbObject::OnConfigUpdate(void)
        BOOST_FOREACH(const Dependency::Ptr& dep, host->GetDependencies()) {
                Checkable::Ptr parent = dep->GetParent();
 
-               if (!parent)
+               if (!parent) {
+                       Log(LogDebug, "db_ido", "Missing parent for dependency '" + dep->GetName() + "'.");
                        continue;
+               }
 
                int state_filter = dep->GetStateFilter();
 
index 109a1aea4ced0ec758acd1d12bd00f78cc51511e..7b3434807a6e5117760916290aa4875e16335542 100644 (file)
@@ -180,8 +180,10 @@ void ServiceDbObject::OnConfigUpdate(void)
        BOOST_FOREACH(const Dependency::Ptr& dep, service->GetDependencies()) {
                Checkable::Ptr parent = dep->GetParent();
 
-               if (!parent)
+               if (!parent) {
+                       Log(LogDebug, "db_ido", "Missing parent for dependency '" + dep->GetName() + "'.");
                        continue;
+               }
 
                Log(LogDebug, "db_ido", "service parents: " + parent->GetName());
 
index 4b74fd6f321c8dacf3e0feec6e2e1986a2baad95..485b1cb4c99c309b5baa347138d2c1dde6de3f5c 100644 (file)
@@ -168,10 +168,13 @@ Checkable::Ptr Dependency::GetParent(void) const
        if (!host)
                return Service::Ptr();
 
-       if (GetParentServiceName().IsEmpty())
+       if (GetParentServiceName().IsEmpty()) {
+               Log(LogDebug, "icinga", "Dependency '" + GetName() + "' parent host '" + GetParentHostName() + ".");
                return host;
-       else
+       } else {
+               Log(LogDebug, "icinga", "Dependency '" + GetName() + "' parent host '" + GetParentHostName() + "' service '" + GetParentServiceName() + "' .");
                return host->GetServiceByShortName(GetParentServiceName());
+       }
 }
 
 TimePeriod::Ptr Dependency::GetPeriod(void) const
index 2dab7c1f44f0dbf3b38e43fcc82063bbff426260..0405516e33752ffb611afeaba305fa1fbd1af5e4 100644 (file)
@@ -30,25 +30,43 @@ object Host "5872-switch" {
   address = "192.168.1.2",
 }
 
-apply Dependency "5872-switch" to Host {
-  child_host_name = "5872-switch"
+apply Dependency "5872-host-switch" to Host {
   parent_host_name = "5872-router"
   disable_checks = true
   assign where host.name == "5872-switch"
 }
 
-apply Dependency "5872-pc" to Host {
-  child_host_name = "5872-pc"
+apply Dependency "5872-host-pc" to Host {
   parent_host_name = "5872-switch"
   disable_checks = true
   assign where host.name == "5872-pc"
 }
 
-apply Dependency "5872-server" to Host {
-  child_host_name = "5872-server"
+apply Dependency "5872-host-server" to Host {
   parent_host_name = "5872-switch"
   disable_checks = true
   assign where host.name == "5872-server"
 }
 
+apply Dependency "5872-service-switch" to Service {
+  parent_host_name = "5872-router"
+  parent_service_name = "5872-ping4"
+  disable_checks = true
+  assign where host.name == "5872-switch"
+}
+
+apply Dependency "5872-service-pc" to Service {
+  parent_host_name = "5872-switch"
+  parent_service_name = "5872-ping4"
+  disable_checks = true
+  assign where host.name == "5872-pc"
+}
+
+apply Dependency "5872-service-server" to Service {
+  parent_host_name = "5872-switch"
+  parent_service_name = "5872-ping4"
+  states = [ Warning, Critical ]
+  disable_checks = true
+  assign where host.name == "5872-server"
+}