/******************************************************************************
* Icinga 2 *
- * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/) *
+ * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
#include "livestatus/servicestable.h"
#include "livestatus/hoststable.h"
+#include "livestatus/endpointstable.h"
#include "icinga/service.h"
#include "icinga/checkcommand.h"
#include "icinga/eventcommand.h"
#include <boost/algorithm/string/replace.hpp>
using namespace icinga;
-using namespace livestatus;
ServicesTable::ServicesTable(void)
{
table->AddColumn(prefix + "accept_passive_checks", Column(&ServicesTable::AcceptPassiveChecksAccessor, objectAccessor));
table->AddColumn(prefix + "event_handler_enabled", Column(&ServicesTable::EventHandlerEnabledAccessor, objectAccessor));
table->AddColumn(prefix + "notifications_enabled", Column(&ServicesTable::NotificationsEnabledAccessor, objectAccessor));
- table->AddColumn(prefix + "process_performance_data", Column(&Table::OneAccessor, objectAccessor));
+ table->AddColumn(prefix + "process_performance_data", Column(&ServicesTable::ProcessPerformanceDataAccessor, objectAccessor));
table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor));
table->AddColumn(prefix + "active_checks_enabled", Column(&ServicesTable::ActiveChecksEnabledAccessor, objectAccessor));
table->AddColumn(prefix + "check_options", Column(&ServicesTable::CheckOptionsAccessor, objectAccessor));
table->AddColumn(prefix + "custom_variables", Column(&ServicesTable::CustomVariablesAccessor, objectAccessor));
table->AddColumn(prefix + "groups", Column(&ServicesTable::GroupsAccessor, objectAccessor));
table->AddColumn(prefix + "contact_groups", Column(&ServicesTable::ContactGroupsAccessor, objectAccessor));
+ table->AddColumn(prefix + "check_source", Column(&ServicesTable::CheckSourceAccessor, objectAccessor));
HostsTable::AddColumns(table, "host_", boost::bind(&ServicesTable::HostAccessor, _1, objectAccessor));
}
if (!service)
return Empty;
- CheckCommand::Ptr commandObj = service->GetCheckCommand();
-
- if (!commandObj)
- return Empty;
-
- Value raw_command = commandObj->GetCommandLine();
-
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(commandObj);
- resolvers.push_back(IcingaApplication::GetInstance());
-
- Value commandLine = MacroProcessor::ResolveMacros(raw_command, resolvers, Dictionary::Ptr(), Utility::EscapeShellCmd);
-
- String buf;
- if (commandLine.IsObjectType<Array>()) {
- Array::Ptr args = commandLine;
+ CheckCommand::Ptr checkcommand = service->GetCheckCommand();
- ObjectLock olock(args);
- String arg;
- BOOST_FOREACH(arg, args) {
- // This is obviously incorrect for non-trivial cases.
- String argitem = " \"" + arg + "\"";
- boost::algorithm::replace_all(argitem, "\n", "\\n");
- buf += argitem;
- }
- } else if (!commandLine.IsEmpty()) {
- String args = Convert::ToString(commandLine);
- boost::algorithm::replace_all(args, "\n", "\\n");
- buf += args;
- } else {
- buf += "<internal>";
- }
+ if (checkcommand)
+ return checkcommand->GetName(); /* this is the name without '!' args */
- return buf;
+ return Empty;
}
Value ServicesTable::EventHandlerAccessor(const Value& row)
return Empty;
String output;
- Dictionary::Ptr cr = service->GetLastCheckResult();
+ CheckResult::Ptr cr = service->GetLastCheckResult();
- if (cr) {
- Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
- output = output_bag->Get("output");
- }
+ if (cr)
+ output = CompatUtility::GetCheckResultOutput(cr);
return output;
}
return Empty;
String long_output;
- Dictionary::Ptr cr = service->GetLastCheckResult();
+ CheckResult::Ptr cr = service->GetLastCheckResult();
- if (cr) {
- Dictionary::Ptr output_bag = CompatUtility::GetCheckResultOutput(cr);
- long_output = output_bag->Get("long_output");
- }
+ if (cr)
+ long_output = CompatUtility::GetCheckResultLongOutput(cr);
return long_output;
}
return Empty;
String perfdata;
- Dictionary::Ptr cr = service->GetLastCheckResult();
+ CheckResult::Ptr cr = service->GetLastCheckResult();
if (cr)
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
if (!service)
return Empty;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- ObjectLock olock(notification);
-
- TimePeriod::Ptr timeperiod = notification->GetNotificationPeriod();
-
- /* XXX first notification wins */
- if (timeperiod)
- return timeperiod->GetName();
- }
-
- return Empty;
+ return CompatUtility::GetCheckableNotificationNotificationPeriod(service);
}
Value ServicesTable::CheckPeriodAccessor(const Value& row)
if (!service)
return Empty;
- TimePeriod::Ptr timeperiod = service->GetCheckPeriod();
-
- if (!timeperiod)
- return Empty;
-
- return timeperiod->GetName();
+ return CompatUtility::GetCheckableCheckPeriod(service);
}
Value ServicesTable::NotesAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- return custom->Get("notes");
+ return service->GetNotes();
}
Value ServicesTable::NotesExpandedAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
-
- Value value = custom->Get("notes");
-
- Dictionary::Ptr cr;
- Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
-
- return value_expanded;
+ return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::NotesUrlAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- return custom->Get("notes_url");
+ return service->GetNotesUrl();
}
Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- if (!custom)
- return Empty;
-
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
-
- Value value = custom->Get("notes_url");
-
- Dictionary::Ptr cr;
- Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
-
- return value_expanded;
+ return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::ActionUrlAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- return custom->Get("action_url");
+ return service->GetActionUrl();
}
Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- Value value = custom->Get("action_url");
-
- Dictionary::Ptr cr;
- Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
-
- return value_expanded;
+ return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::IconImageAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- return custom->Get("icon_image");
+ return service->GetIconImage();
}
Value ServicesTable::IconImageExpandedAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
-
- Value value = custom->Get("icon_image");
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- Dictionary::Ptr cr;
- Value value_expanded = MacroProcessor::ResolveMacros(value, resolvers, cr, Utility::EscapeShellCmd);
-
- return value_expanded;
+ return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::IconImageAltAccessor(const Value& row)
if (!service)
return Empty;
- Dictionary::Ptr custom = service->GetCustom();
-
- if (!custom)
- return Empty;
-
- return custom->Get("icon_image_alt");
+ return service->GetIconImageAlt();
}
Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
if (!service)
return Empty;
- return (service->HasBeenChecked() ? 1 : 0);
+ return CompatUtility::GetCheckableHasBeenChecked(service);
}
Value ServicesTable::LastStateAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetEnableActiveChecks() ? 0 : 1);
+ return CompatUtility::GetCheckableCheckType(service);
}
Value ServicesTable::AcknowledgedAccessor(const Value& row)
if (!service)
return Empty;
- /* important: lock acknowledgements */
- ObjectLock olock(service);
-
- return (service->IsAcknowledged() ? 1 : 0);
+ return CompatUtility::GetCheckableIsAcknowledged(service);
}
Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
if (!service)
return Empty;
- /* XXX take the smallest notification_interval */
- double notification_interval = -1;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
- notification_interval = notification->GetNotificationInterval();
- }
-
- if (notification_interval == 0 && !service->GetVolatile())
- return 1;
-
- return 0;
+ return CompatUtility::GetCheckableNoMoreNotifications(service);
}
Value ServicesTable::LastTimeOkAccessor(const Value& row)
if (!service)
return Empty;
- /* XXX Service -> Notifications, latest wins */
- double last_notification = 0;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- if (notification->GetLastNotification() > last_notification)
- last_notification = notification->GetLastNotification();
- }
-
- return static_cast<int>(last_notification);
+ return CompatUtility::GetCheckableNotificationLastNotification(service);
}
Value ServicesTable::NextNotificationAccessor(const Value& row)
if (!service)
return Empty;
- /* XXX Service -> Notifications, latest wins */
- double next_notification = 0;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- if (notification->GetNextNotification() < next_notification)
- next_notification = notification->GetNextNotification();
- }
-
- return static_cast<int>(next_notification);
+ return CompatUtility::GetCheckableNotificationNextNotification(service);
}
Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
if (!service)
return Empty;
- /* XXX Service -> Notifications, biggest wins */
- int notification_number = 0;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- if (notification->GetNotificationNumber() > notification_number)
- notification_number = notification->GetNotificationNumber();
- }
-
- return notification_number;
+ return CompatUtility::GetCheckableNotificationNotificationNumber(service);
}
Value ServicesTable::LastStateChangeAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetEnableActiveChecks() ? 1 : 0);
+ return CompatUtility::GetCheckableActiveChecksEnabled(service);
}
Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetEnablePassiveChecks() ? 1 : 0);
+ return CompatUtility::GetCheckablePassiveChecksEnabled(service);
}
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
if (!service)
return Empty;
- EventCommand::Ptr eventcommand = service->GetEventCommand();
+ return CompatUtility::GetCheckableEventHandlerEnabled(service);
+}
- if (eventcommand)
- return 1;
+Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
+{
+ Service::Ptr service = static_cast<Service::Ptr>(row);
+
+ if (!service)
+ return Empty;
- return 0;
+ return CompatUtility::GetCheckableNotificationsEnabled(service);
}
-Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
+Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row)
{
Service::Ptr service = static_cast<Service::Ptr>(row);
if (!service)
return Empty;
- return (service->GetEnableNotifications() ? 1 : 0);
+ return CompatUtility::GetCheckableProcessPerformanceData(service);
}
Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetEnableActiveChecks() ? 1 : 0);
+ return CompatUtility::GetCheckableActiveChecksEnabled(service);
}
Value ServicesTable::CheckOptionsAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetEnableFlapping() ? 1 : 0);
+ return CompatUtility::GetCheckableFlapDetectionEnabled(service);
}
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
{
- /* always enabled */
- return 1;
+ Service::Ptr service = static_cast<Service::Ptr>(row);
+
+ if (!service)
+ return Empty;
+
+ return CompatUtility::GetCheckableFreshnessChecksEnabled(service);
}
Value ServicesTable::ModifiedAttributesAccessor(const Value& row)
if (!service)
return Empty;
- if (service->HasBeenChecked() && service->GetLastCheck() > 0)
- return (Utility::GetTime() - service->GetLastCheck()) / (service->GetCheckInterval() * 3600);
-
- return Empty;
+ return CompatUtility::GetCheckableStaleness(service);
}
Value ServicesTable::CheckIntervalAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetCheckInterval() / 60.0);
+ return CompatUtility::GetCheckableCheckInterval(service);
}
Value ServicesTable::RetryIntervalAccessor(const Value& row)
if (!service)
return Empty;
- return (service->GetRetryInterval() / 60.0);
+ return CompatUtility::GetCheckableRetryInterval(service);
}
Value ServicesTable::NotificationIntervalAccessor(const Value& row)
if (!service)
return Empty;
- /* XXX take the smallest notification_interval */
- double notification_interval = -1;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
- notification_interval = notification->GetNotificationInterval();
- }
-
- if (notification_interval == -1)
- notification_interval = 60;
-
- return (notification_interval / 60.0);
+ return CompatUtility::GetCheckableNotificationNotificationInterval(service);
}
Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
if (!service)
return Empty;
- return service->GetFlappingThreshold();
+ return CompatUtility::GetCheckableLowFlapThreshold(service);
}
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
if (!service)
return Empty;
- return service->GetFlappingThreshold();
+ return CompatUtility::GetCheckableHighFlapThreshold(service);
}
Value ServicesTable::LatencyAccessor(const Value& row)
if (!service)
return Empty;
- return service->GetFlappingCurrent();
+ return CompatUtility::GetCheckablePercentStateChange(service);
}
Value ServicesTable::InCheckPeriodAccessor(const Value& row)
if (!service)
return Empty;
- TimePeriod::Ptr timeperiod = service->GetCheckPeriod();
-
- /* none set means always checked */
- if (!timeperiod)
- return 1;
-
- return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
+ return CompatUtility::GetCheckableInCheckPeriod(service);
}
Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
if (!service)
return Empty;
- BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
- ObjectLock olock(notification);
-
- TimePeriod::Ptr timeperiod = notification->GetNotificationPeriod();
-
- /* XXX first notification wins */
- if (timeperiod)
- return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
- }
-
- /* none set means always notified */
- return 1;
+ return CompatUtility::GetCheckableInNotificationPeriod(service);
}
Value ServicesTable::ContactsAccessor(const Value& row)
if (!service)
return Empty;
- Array::Ptr contact_names = boost::make_shared<Array>();
+ Array::Ptr contact_names = make_shared<Array>();
- BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetServiceNotificationUsers(service)) {
+ BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) {
contact_names->Add(user->GetName());
}
Dictionary::Ptr downtimes = service->GetDowntimes();
- Array::Ptr ids = boost::make_shared<Array>();
+ Array::Ptr ids = make_shared<Array>();
ObjectLock olock(downtimes);
String id;
- Dictionary::Ptr downtime;
- BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+ Downtime::Ptr downtime;
+ BOOST_FOREACH(tie(id, downtime), downtimes) {
if (!downtime)
continue;
- if (Service::IsDowntimeExpired(downtime))
+ if (downtime->IsExpired())
continue;
- ids->Add(downtime->Get("legacy_id"));
+ ids->Add(downtime->GetLegacyId());
}
return ids;
Dictionary::Ptr downtimes = service->GetDowntimes();
- Array::Ptr ids = boost::make_shared<Array>();
+ Array::Ptr ids = make_shared<Array>();
ObjectLock olock(downtimes);
String id;
- Dictionary::Ptr downtime;
- BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+ Downtime::Ptr downtime;
+ BOOST_FOREACH(tie(id, downtime), downtimes) {
if (!downtime)
continue;
- if (Service::IsDowntimeExpired(downtime))
+ if (downtime->IsExpired())
continue;
- Array::Ptr downtime_info = boost::make_shared<Array>();
- downtime_info->Add(downtime->Get("legacy_id"));
- downtime_info->Add(downtime->Get("author"));
- downtime_info->Add(downtime->Get("comment"));
+ Array::Ptr downtime_info = make_shared<Array>();
+ downtime_info->Add(downtime->GetLegacyId());
+ downtime_info->Add(downtime->GetAuthor());
+ downtime_info->Add(downtime->GetComment());
ids->Add(downtime_info);
}
Dictionary::Ptr comments = service->GetComments();
- Array::Ptr ids = boost::make_shared<Array>();
+ Array::Ptr ids = make_shared<Array>();
ObjectLock olock(comments);
String id;
- Dictionary::Ptr comment;
- BOOST_FOREACH(boost::tie(id, comment), comments) {
+ Comment::Ptr comment;
+ BOOST_FOREACH(tie(id, comment), comments) {
if (!comment)
continue;
- if (Service::IsCommentExpired(comment))
+ if (comment->IsExpired())
continue;
- ids->Add(comment->Get("legacy_id"));
+ ids->Add(comment->GetLegacyId());
}
return ids;
Dictionary::Ptr comments = service->GetComments();
- Array::Ptr ids = boost::make_shared<Array>();
+ Array::Ptr ids = make_shared<Array>();
ObjectLock olock(comments);
String id;
- Dictionary::Ptr comment;
- BOOST_FOREACH(boost::tie(id, comment), comments) {
+ Comment::Ptr comment;
+ BOOST_FOREACH(tie(id, comment), comments) {
if (!comment)
continue;
- if (Service::IsCommentExpired(comment))
+ if (comment->IsExpired())
continue;
- Array::Ptr comment_info = boost::make_shared<Array>();
- comment_info->Add(comment->Get("legacy_id"));
- comment_info->Add(comment->Get("author"));
- comment_info->Add(comment->Get("text"));
+ Array::Ptr comment_info = make_shared<Array>();
+ comment_info->Add(comment->GetLegacyId());
+ comment_info->Add(comment->GetAuthor());
+ comment_info->Add(comment->GetText());
ids->Add(comment_info);
}
Dictionary::Ptr comments = service->GetComments();
- Array::Ptr ids = boost::make_shared<Array>();
+ Array::Ptr ids = make_shared<Array>();
ObjectLock olock(comments);
String id;
- Dictionary::Ptr comment;
- BOOST_FOREACH(boost::tie(id, comment), comments) {
+ Comment::Ptr comment;
+ BOOST_FOREACH(tie(id, comment), comments) {
if (!comment)
continue;
- if (Service::IsCommentExpired(comment))
+ if (comment->IsExpired())
continue;
- Array::Ptr comment_info = boost::make_shared<Array>();
- comment_info->Add(comment->Get("legacy_id"));
- comment_info->Add(comment->Get("author"));
- comment_info->Add(comment->Get("text"));
- comment_info->Add(comment->Get("entry_type"));
- comment_info->Add(static_cast<int>(comment->Get("entry_time")));
+ Array::Ptr comment_info = make_shared<Array>();
+ comment_info->Add(comment->GetLegacyId());
+ comment_info->Add(comment->GetAuthor());
+ comment_info->Add(comment->GetText());
+ comment_info->Add(comment->GetEntryType());
+ comment_info->Add(static_cast<int>(comment->GetEntryTime()));
ids->Add(comment_info);
}
if (!service)
return Empty;
- Dictionary::Ptr customvars;
+ Dictionary::Ptr vars;
{
ObjectLock olock(service);
- customvars = CompatUtility::GetCustomVariableConfig(service);
+ vars = CompatUtility::GetCustomAttributeConfig(service);
}
- if (!customvars)
+ if (!vars)
return Empty;
- Array::Ptr cv = boost::make_shared<Array>();
+ Array::Ptr cv = make_shared<Array>();
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), customvars) {
+ BOOST_FOREACH(tie(key, value), vars) {
cv->Add(key);
}
if (!service)
return Empty;
- Dictionary::Ptr customvars;
+ Dictionary::Ptr vars;
{
ObjectLock olock(service);
- customvars = CompatUtility::GetCustomVariableConfig(service);
+ vars = CompatUtility::GetCustomAttributeConfig(service);
}
- if (!customvars)
+ if (!vars)
return Empty;
- Array::Ptr cv = boost::make_shared<Array>();
+ Array::Ptr cv = make_shared<Array>();
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), customvars) {
+ BOOST_FOREACH(tie(key, value), vars) {
cv->Add(value);
}
if (!service)
return Empty;
- Dictionary::Ptr customvars;
+ Dictionary::Ptr vars;
{
ObjectLock olock(service);
- customvars = CompatUtility::GetCustomVariableConfig(service);
+ vars = CompatUtility::GetCustomAttributeConfig(service);
}
- if (!customvars)
+ if (!vars)
return Empty;
- Array::Ptr cv = boost::make_shared<Array>();
+ Array::Ptr cv = make_shared<Array>();
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), customvars) {
- Array::Ptr key_val = boost::make_shared<Array>();
+ BOOST_FOREACH(tie(key, value), vars) {
+ Array::Ptr key_val = make_shared<Array>();
key_val->Add(key);
key_val->Add(value);
cv->Add(key_val);
if (!service)
return Empty;
- Array::Ptr contactgroup_names = boost::make_shared<Array>();
+ Array::Ptr contactgroup_names = make_shared<Array>();
- BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetServiceNotificationUserGroups(service)) {
+ BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) {
contactgroup_names->Add(usergroup->GetName());
}
return contactgroup_names;
}
+Value ServicesTable::CheckSourceAccessor(const Value& row)
+{
+ Service::Ptr service = static_cast<Service::Ptr>(row);
+
+ if (!service)
+ return Empty;
+
+ CheckResult::Ptr cr = service->GetLastCheckResult();
+
+ if (cr)
+ return cr->GetCheckSource();
+
+ return Empty;
+}
+