diff --git a/components/livestatus/hoststable.cpp b/components/livestatus/hoststable.cpp index 42df97add..cefd68923 100644 --- a/components/livestatus/hoststable.cpp +++ b/components/livestatus/hoststable.cpp @@ -1088,7 +1088,15 @@ Value HostsTable::ContactsAccessor(const Value& row) if (!hc) return Empty; - return CompatUtility::GetServiceNotificationUsers(hc); + Array::Ptr contacts = CompatUtility::GetServiceNotificationUsers(hc); + Array::Ptr contact_names = boost::make_shared(); + + ObjectLock olock(contacts); + BOOST_FOREACH(const User::Ptr& user, contacts) { + contact_names->Add(user->GetName()); + } + + return contact_names; } Value HostsTable::DowntimesAccessor(const Value& row) @@ -1581,7 +1589,16 @@ Value HostsTable::ContactGroupsAccessor(const Value& row) if (!hc) return Empty; - return CompatUtility::GetServiceNotificationUserGroups(hc); + Array::Ptr contactgroups = CompatUtility::GetServiceNotificationUserGroups(hc); + + Array::Ptr contactgroup_names = boost::make_shared(); + + ObjectLock olock(contactgroups); + BOOST_FOREACH(const UserGroup::Ptr& usergroup, contactgroups) { + contactgroup_names->Add(usergroup->GetName()); + } + + return contactgroup_names; } Value HostsTable::ServicesAccessor(const Value& row) diff --git a/components/livestatus/servicestable.cpp b/components/livestatus/servicestable.cpp index 89a0d0d15..396b4b1e7 100644 --- a/components/livestatus/servicestable.cpp +++ b/components/livestatus/servicestable.cpp @@ -751,7 +751,15 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row) Value ServicesTable::ContactsAccessor(const Value& row) { - return CompatUtility::GetServiceNotificationUsers(static_cast(row)); + Array::Ptr contacts = CompatUtility::GetServiceNotificationUsers(static_cast(row)); + Array::Ptr contact_names = boost::make_shared(); + + ObjectLock olock(contacts); + BOOST_FOREACH(const User::Ptr& user, contacts) { + contact_names->Add(user->GetName()); + } + + return contact_names; } Value ServicesTable::DowntimesAccessor(const Value& row) @@ -1002,7 +1010,16 @@ Value ServicesTable::GroupsAccessor(const Value& row) Value ServicesTable::ContactGroupsAccessor(const Value& row) { - return CompatUtility::GetServiceNotificationUserGroups(static_cast(row)); + Array::Ptr contactgroups = CompatUtility::GetServiceNotificationUserGroups(static_cast(row)); + + Array::Ptr contactgroup_names = boost::make_shared(); + + ObjectLock olock(contactgroups); + BOOST_FOREACH(const UserGroup::Ptr& usergroup, contactgroups) { + contactgroup_names->Add(usergroup->GetName()); + } + + return contactgroup_names; } diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index e59346e2d..9fa6b96d8 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -504,7 +504,7 @@ Value CompatUtility::GetServiceNotificationUsers(const Service::Ptr& service) } BOOST_FOREACH(const User::Ptr& user, allUsers) { - contacts->Add(user->GetName()); + contacts->Add(user); } return contacts; @@ -519,7 +519,7 @@ Value CompatUtility::GetServiceNotificationUserGroups(const Service::Ptr& servic ObjectLock olock(notification); BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) { - contactgroups->Add(ug->GetName()); + contactgroups->Add(ug); } }