]> granicus.if.org Git - icinga2/commitdiff
livestatus: fix HostsTable::ContactGroupsAccessor()
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 19 Jul 2013 14:24:09 +0000 (16:24 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Fri, 19 Jul 2013 14:24:09 +0000 (16:24 +0200)
refs #4372

components/livestatus/hoststable.cpp

index 50bf2a81cc00a1f2530baa6563bd1a6508e7fccc..991afd8bb7d9a5b7d335c9515460e21f0d879f91 100644 (file)
@@ -1593,10 +1593,16 @@ Value HostsTable::GroupsAccessor(const Value& row)
 
 Value HostsTable::ContactGroupsAccessor(const Value& row)
 {
+       /* use hostcheck service */
+       Service::Ptr hc = static_cast<Host::Ptr>(row)->GetHostCheckService();
+
+       if (!hc)
+               return Empty;
+
        /* XXX Service -> Notifications -> UserGroups */
        Array::Ptr contactgroups = boost::make_shared<Array>();
 
-       BOOST_FOREACH(const Notification::Ptr& notification, static_cast<Service::Ptr>(row)->GetNotifications()) {
+       BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) {
                ObjectLock olock(notification);
 
                BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetGroups()) {