diff --git a/lib/ido/hostgroupdbobject.cpp b/lib/ido/hostgroupdbobject.cpp index fab1b7a36..0517300de 100644 --- a/lib/ido/hostgroupdbobject.cpp +++ b/lib/ido/hostgroupdbobject.cpp @@ -20,7 +20,6 @@ #include "ido/hostgroupdbobject.h" #include "ido/dbtype.h" #include "ido/dbvalue.h" -#include "icinga/hostgroup.h" #include "base/objectlock.h" #include "base/initialize.h" #include "base/dynamictype.h" @@ -37,7 +36,7 @@ HostGroupDbObject::HostGroupDbObject(const DbType::Ptr& type, const String& name void HostGroupDbObject::StaticInitialize(void) { - HostGroup::OnMembersChanged.connect(&HostGroupDbObject::MembersChangedHandler); + HostGroup::OnMembersChanged.connect(boost::bind(&HostGroupDbObject::MembersChangedHandler, HostGroup::Ptr())); } Dictionary::Ptr HostGroupDbObject::GetConfigFields(void) const @@ -57,10 +56,11 @@ Dictionary::Ptr HostGroupDbObject::GetStatusFields(void) const void HostGroupDbObject::OnConfigUpdate(void) { - MembersChangedHandler(); + HostGroup::Ptr group = static_pointer_cast(GetObject()); + MembersChangedHandler(group); } -void HostGroupDbObject::MembersChangedHandler(void) +void HostGroupDbObject::MembersChangedHandler(const HostGroup::Ptr& hgfilter) { DbQuery query1; query1.Table = DbType::GetByName("HostGroup")->GetTable() + "_members"; @@ -72,6 +72,9 @@ void HostGroupDbObject::MembersChangedHandler(void) BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("HostGroup")) { HostGroup::Ptr hg = static_pointer_cast(object); + if (hgfilter && hg != hgfilter) + continue; + BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) { DbQuery query2; query2.Table = DbType::GetByName("HostGroup")->GetTable() + "_members"; diff --git a/lib/ido/hostgroupdbobject.h b/lib/ido/hostgroupdbobject.h index a09399045..07fe7d150 100644 --- a/lib/ido/hostgroupdbobject.h +++ b/lib/ido/hostgroupdbobject.h @@ -21,6 +21,7 @@ #define HOSTGROUPDBOBJECT_H #include "ido/dbobject.h" +#include "icinga/hostgroup.h" #include "base/dynamicobject.h" namespace icinga @@ -47,7 +48,7 @@ protected: virtual void OnConfigUpdate(void); private: - static void MembersChangedHandler(void); + static void MembersChangedHandler(const HostGroup::Ptr& hgfilter); }; }