#include "icinga/timeperiod.h"
#include "icinga/macroprocessor.h"
#include "icinga/icingaapplication.h"
+#include "icinga/compatutility.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/convert.h"
if (!hc)
return Empty;
- std::set<User::Ptr> allUsers;
- std::set<User::Ptr> users;
- Array::Ptr contacts = boost::make_shared<Array>();
-
- BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) {
- ObjectLock olock(notification);
-
- users = notification->GetUsers();
-
- std::copy(users.begin(), users.end(), std::inserter(allUsers, allUsers.begin()));
-
- BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
- std::set<User::Ptr> members = ug->GetMembers();
- std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
- }
- }
-
- BOOST_FOREACH(const User::Ptr& user, allUsers) {
- contacts->Add(user->GetName());
- }
-
- return contacts;
+ return CompatUtility::GetServiceNotificationUsers(hc);
}
Value HostsTable::DowntimesAccessor(const Value& row)
if (!hc)
return Empty;
- /* XXX Service -> Notifications -> UserGroups */
- Array::Ptr contactgroups = boost::make_shared<Array>();
-
- BOOST_FOREACH(const Notification::Ptr& notification, hc->GetNotifications()) {
- ObjectLock olock(notification);
-
- BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
- contactgroups->Add(ug->GetName());
- }
- }
-
- return contactgroups;
+ return CompatUtility::GetServiceNotificationUserGroups(hc);
}
Value HostsTable::ServicesAccessor(const Value& row)
#include "icinga/timeperiod.h"
#include "icinga/macroprocessor.h"
#include "icinga/icingaapplication.h"
+#include "icinga/compatutility.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/convert.h"
Value ServicesTable::ContactsAccessor(const Value& row)
{
- /* XXX Service -> Notifications -> (Users + UserGroups -> Users) */
- std::set<User::Ptr> allUsers;
- std::set<User::Ptr> users;
- Array::Ptr contacts = boost::make_shared<Array>();
-
- BOOST_FOREACH(const Notification::Ptr& notification, static_cast<Service::Ptr>(row)->GetNotifications()) {
- ObjectLock olock(notification);
-
- users = notification->GetUsers();
-
- std::copy(users.begin(), users.end(), std::inserter(allUsers, allUsers.begin()));
-
- BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
- std::set<User::Ptr> members = ug->GetMembers();
- std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
- }
- }
-
- BOOST_FOREACH(const User::Ptr& user, allUsers) {
- contacts->Add(user->GetName());
- }
-
- return contacts;
+ return CompatUtility::GetServiceNotificationUsers(static_cast<Service::Ptr>(row));
}
Value ServicesTable::DowntimesAccessor(const Value& row)
Value ServicesTable::ContactGroupsAccessor(const Value& row)
{
- /* XXX Service -> Notifications -> UserGroups */
- Array::Ptr contactgroups = boost::make_shared<Array>();
-
- BOOST_FOREACH(const Notification::Ptr& notification, static_cast<Service::Ptr>(row)->GetNotifications()) {
- ObjectLock olock(notification);
-
- BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
- contactgroups->Add(ug->GetName());
- }
- }
-
- return contactgroups;
+ return CompatUtility::GetServiceNotificationUserGroups(static_cast<Service::Ptr>(row));
}
return customvars;
}
+Value CompatUtility::GetServiceNotificationUsers(const Service::Ptr& service)
+{
+ /* Service -> Notifications -> (Users + UserGroups -> Users) */
+ std::set<User::Ptr> allUsers;
+ std::set<User::Ptr> users;
+ Array::Ptr contacts = boost::make_shared<Array>();
+
+ BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
+ ObjectLock olock(notification);
+
+ users = notification->GetUsers();
+
+ std::copy(users.begin(), users.end(), std::inserter(allUsers, allUsers.begin()));
+
+ BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
+ std::set<User::Ptr> members = ug->GetMembers();
+ std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
+ }
+ }
+
+ BOOST_FOREACH(const User::Ptr& user, allUsers) {
+ contacts->Add(user->GetName());
+ }
+
+ return contacts;
+}
+
+Value CompatUtility::GetServiceNotificationUserGroups(const Service::Ptr& service)
+{
+ /* Service -> Notifications -> UserGroups */
+ Array::Ptr contactgroups = boost::make_shared<Array>();
+
+ BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
+ ObjectLock olock(notification);
+
+ BOOST_FOREACH(const UserGroup::Ptr& ug, notification->GetUserGroups()) {
+ contactgroups->Add(ug->GetName());
+ }
+ }
+
+ return contactgroups;
+}
+
Dictionary::Ptr CompatUtility::GetCheckResultOutput(const Dictionary::Ptr& cr)
{
if (!cr)
static Dictionary::Ptr GetCustomVariableConfig(const DynamicObject::Ptr& object);
+ static Value GetServiceNotificationUsers(const Service::Ptr& service);
+ static Value GetServiceNotificationUserGroups(const Service::Ptr& service);
+
static Dictionary::Ptr GetCheckResultOutput(const Dictionary::Ptr& cr);
static String GetCheckResultPerfdata(const Dictionary::Ptr& cr);