From f0f3412f2c34379b26b153e782c9463d346a4028 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 19 Jul 2013 16:11:17 +0200 Subject: [PATCH] add GetChildHosts() to host object --- lib/icinga/host.cpp | 23 +++++++++++++++++++++++ lib/icinga/host.h | 1 + 2 files changed, 24 insertions(+) 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; -- 2.40.0