diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index 45ee60847..4ef46cfab 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -461,6 +461,29 @@ std::set Host::GetParentHosts(void) const return parents; } +std::set Host::GetChildHosts(void) const +{ + std::set childs; + + BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Host")) { + const Host::Ptr& host = static_pointer_cast(object); + + Array::Ptr dependencies = host->GetHostDependencies(); + + if (dependencies) { + ObjectLock olock(dependencies); + + BOOST_FOREACH(const Value& value, dependencies) { + if (value == GetName()) + childs.insert(host); + } + } + } + + return childs; + +} + Service::Ptr Host::GetHostCheckService(void) const { String host_check = GetHostCheck(); diff --git a/lib/icinga/host.h b/lib/icinga/host.h index 176cfa6c9..f87d304d1 100644 --- a/lib/icinga/host.h +++ b/lib/icinga/host.h @@ -94,6 +94,7 @@ public: shared_ptr GetHostCheckService(void) const; std::set GetParentHosts(void) const; + std::set GetChildHosts(void) const; std::set > GetParentServices(void) const; bool IsReachable() const;