2013-03-10 22:20:13 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2015-01-22 12:00:23 +01:00
|
|
|
* Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
|
2013-03-10 22:20:13 +01:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "livestatus/servicestable.hpp"
|
|
|
|
#include "livestatus/hoststable.hpp"
|
2015-02-13 15:50:20 +01:00
|
|
|
#include "livestatus/servicegroupstable.hpp"
|
|
|
|
#include "livestatus/hostgroupstable.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "livestatus/endpointstable.hpp"
|
|
|
|
#include "icinga/service.hpp"
|
2015-02-13 15:50:20 +01:00
|
|
|
#include "icinga/servicegroup.hpp"
|
|
|
|
#include "icinga/hostgroup.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/checkcommand.hpp"
|
|
|
|
#include "icinga/eventcommand.hpp"
|
|
|
|
#include "icinga/timeperiod.hpp"
|
|
|
|
#include "icinga/macroprocessor.hpp"
|
|
|
|
#include "icinga/icingaapplication.hpp"
|
|
|
|
#include "icinga/compatutility.hpp"
|
2015-08-15 20:28:05 +02:00
|
|
|
#include "base/configtype.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "base/objectlock.hpp"
|
2014-11-04 16:44:45 +01:00
|
|
|
#include "base/json.hpp"
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "base/convert.hpp"
|
|
|
|
#include "base/utility.hpp"
|
2013-03-16 21:18:53 +01:00
|
|
|
#include <boost/foreach.hpp>
|
2013-07-16 17:58:23 +02:00
|
|
|
#include <boost/tuple/tuple.hpp>
|
2013-07-30 22:38:33 +02:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2013-03-10 22:20:13 +01:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
2015-02-13 15:50:20 +01:00
|
|
|
ServicesTable::ServicesTable(LivestatusGroupByType type)
|
|
|
|
: Table(type)
|
2013-03-10 22:20:13 +01:00
|
|
|
{
|
|
|
|
AddColumns(this);
|
|
|
|
}
|
|
|
|
|
2015-02-13 15:50:20 +01:00
|
|
|
|
2013-03-10 22:20:13 +01:00
|
|
|
void ServicesTable::AddColumns(Table *table, const String& prefix,
|
|
|
|
const Column::ObjectAccessor& objectAccessor)
|
|
|
|
{
|
|
|
|
table->AddColumn(prefix + "description", Column(&ServicesTable::ShortNameAccessor, objectAccessor));
|
2014-06-12 11:59:21 +02:00
|
|
|
table->AddColumn(prefix + "service_description", Column(&ServicesTable::ShortNameAccessor, objectAccessor)); //ugly compatibility hack
|
2013-03-10 22:20:13 +01:00
|
|
|
table->AddColumn(prefix + "display_name", Column(&ServicesTable::DisplayNameAccessor, objectAccessor));
|
2013-07-08 17:09:15 +02:00
|
|
|
table->AddColumn(prefix + "check_command", Column(&ServicesTable::CheckCommandAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_command_expanded", Column(&ServicesTable::CheckCommandExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "event_handler", Column(&ServicesTable::EventHandlerAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "plugin_output", Column(&ServicesTable::PluginOutputAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "long_plugin_output", Column(&ServicesTable::LongPluginOutputAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "perf_data", Column(&ServicesTable::PerfDataAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notification_period", Column(&ServicesTable::NotificationPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_period", Column(&ServicesTable::CheckPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes", Column(&ServicesTable::NotesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_expanded", Column(&ServicesTable::NotesExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_url", Column(&ServicesTable::NotesUrlAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_url_expanded", Column(&ServicesTable::NotesUrlExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "action_url", Column(&ServicesTable::ActionUrlAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "action_url_expanded", Column(&ServicesTable::ActionUrlExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "icon_image", Column(&ServicesTable::IconImageAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "icon_image_expanded", Column(&ServicesTable::IconImageExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "icon_image_alt", Column(&ServicesTable::IconImageAltAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "initial_state", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-08 17:09:15 +02:00
|
|
|
table->AddColumn(prefix + "max_check_attempts", Column(&ServicesTable::MaxCheckAttemptsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "current_attempt", Column(&ServicesTable::CurrentAttemptAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "state", Column(&ServicesTable::StateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "has_been_checked", Column(&ServicesTable::HasBeenCheckedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_state", Column(&ServicesTable::LastStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_hard_state", Column(&ServicesTable::LastHardStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "state_type", Column(&ServicesTable::StateTypeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_type", Column(&ServicesTable::CheckTypeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "acknowledged", Column(&ServicesTable::AcknowledgedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "acknowledgement_type", Column(&ServicesTable::AcknowledgementTypeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "no_more_notifications", Column(&ServicesTable::NoMoreNotificationsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_ok", Column(&ServicesTable::LastTimeOkAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_warning", Column(&ServicesTable::LastTimeWarningAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_critical", Column(&ServicesTable::LastTimeCriticalAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_unknown", Column(&ServicesTable::LastTimeUnknownAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_check", Column(&ServicesTable::LastCheckAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "next_check", Column(&ServicesTable::NextCheckAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_notification", Column(&ServicesTable::LastNotificationAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "next_notification", Column(&ServicesTable::NextNotificationAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "current_notification_number", Column(&ServicesTable::CurrentNotificationNumberAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_state_change", Column(&ServicesTable::LastStateChangeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_hard_state_change", Column(&ServicesTable::LastHardStateChangeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "scheduled_downtime_depth", Column(&ServicesTable::ScheduledDowntimeDepthAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "is_flapping", Column(&ServicesTable::IsFlappingAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "checks_enabled", Column(&ServicesTable::ChecksEnabledAccessor, objectAccessor));
|
|
|
|
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));
|
2014-03-12 15:21:56 +01:00
|
|
|
table->AddColumn(prefix + "process_performance_data", Column(&ServicesTable::ProcessPerformanceDataAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-08 17:09:15 +02:00
|
|
|
table->AddColumn(prefix + "active_checks_enabled", Column(&ServicesTable::ActiveChecksEnabledAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_options", Column(&ServicesTable::CheckOptionsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "flap_detection_enabled", Column(&ServicesTable::FlapDetectionEnabledAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_freshness", Column(&ServicesTable::CheckFreshnessAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "obsess_over_service", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-08 17:09:15 +02:00
|
|
|
table->AddColumn(prefix + "modified_attributes", Column(&ServicesTable::ModifiedAttributesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "modified_attributes_list", Column(&ServicesTable::ModifiedAttributesListAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "pnpgraph_present", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-19 14:19:09 +02:00
|
|
|
table->AddColumn(prefix + "staleness", Column(&ServicesTable::StalenessAccessor, objectAccessor));
|
2013-07-08 17:09:15 +02:00
|
|
|
table->AddColumn(prefix + "check_interval", Column(&ServicesTable::CheckIntervalAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "retry_interval", Column(&ServicesTable::RetryIntervalAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notification_interval", Column(&ServicesTable::NotificationIntervalAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "first_notification_delay", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-08 17:09:15 +02:00
|
|
|
table->AddColumn(prefix + "low_flap_threshold", Column(&ServicesTable::LowFlapThresholdAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "high_flap_threshold", Column(&ServicesTable::HighFlapThresholdAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "latency", Column(&ServicesTable::LatencyAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "execution_time", Column(&ServicesTable::ExecutionTimeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "percent_state_change", Column(&ServicesTable::PercentStateChangeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "in_check_period", Column(&ServicesTable::InCheckPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "in_notification_period", Column(&ServicesTable::InNotificationPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "contacts", Column(&ServicesTable::ContactsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "downtimes", Column(&ServicesTable::DowntimesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "downtimes_with_info", Column(&ServicesTable::DowntimesWithInfoAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "comments", Column(&ServicesTable::CommentsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "comments_with_info", Column(&ServicesTable::CommentsWithInfoAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "comments_with_extra_info", Column(&ServicesTable::CommentsWithExtraInfoAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "custom_variable_names", Column(&ServicesTable::CustomVariableNamesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "custom_variable_values", Column(&ServicesTable::CustomVariableValuesAccessor, 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));
|
2014-03-20 19:15:19 +01:00
|
|
|
table->AddColumn(prefix + "check_source", Column(&ServicesTable::CheckSourceAccessor, objectAccessor));
|
2014-05-10 20:37:09 +02:00
|
|
|
table->AddColumn(prefix + "is_reachable", Column(&ServicesTable::IsReachableAccessor, objectAccessor));
|
2014-11-04 16:44:45 +01:00
|
|
|
table->AddColumn(prefix + "cv_is_json", Column(&ServicesTable::CVIsJsonAccessor, objectAccessor));
|
2013-03-10 22:20:13 +01:00
|
|
|
|
2013-07-10 16:11:40 +02:00
|
|
|
HostsTable::AddColumns(table, "host_", boost::bind(&ServicesTable::HostAccessor, _1, objectAccessor));
|
2015-02-13 15:50:20 +01:00
|
|
|
|
|
|
|
/* add additional group by values received through the object accessor */
|
|
|
|
if (table->GetGroupByType() == LivestatusGroupByServiceGroup) {
|
|
|
|
/* _1 = row, _2 = groupByType, _3 = groupByObject */
|
|
|
|
Log(LogDebug, "Livestatus")
|
|
|
|
<< "Processing services group by servicegroup table.";
|
|
|
|
ServiceGroupsTable::AddColumns(table, "servicegroup_", boost::bind(&ServicesTable::ServiceGroupAccessor, _1, _2, _3));
|
|
|
|
} else if (table->GetGroupByType() == LivestatusGroupByHostGroup) {
|
|
|
|
/* _1 = row, _2 = groupByType, _3 = groupByObject */
|
|
|
|
Log(LogDebug, "Livestatus")
|
|
|
|
<< "Processing services group by hostgroup table.";
|
|
|
|
HostGroupsTable::AddColumns(table, "hostgroup_", boost::bind(&ServicesTable::HostGroupAccessor, _1, _2, _3));
|
|
|
|
}
|
2013-03-10 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
String ServicesTable::GetName(void) const
|
|
|
|
{
|
|
|
|
return "services";
|
|
|
|
}
|
|
|
|
|
2014-06-25 11:30:27 +02:00
|
|
|
String ServicesTable::GetPrefix(void) const
|
|
|
|
{
|
|
|
|
return "service";
|
|
|
|
}
|
|
|
|
|
2013-03-15 18:21:29 +01:00
|
|
|
void ServicesTable::FetchRows(const AddRowFunction& addRowFn)
|
2013-03-10 22:20:13 +01:00
|
|
|
{
|
2015-02-13 15:50:20 +01:00
|
|
|
if (GetGroupByType() == LivestatusGroupByServiceGroup) {
|
2015-08-15 20:28:05 +02:00
|
|
|
BOOST_FOREACH(const ServiceGroup::Ptr& sg, ConfigType::GetObjectsByType<ServiceGroup>()) {
|
2015-02-13 15:50:20 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
|
|
|
|
/* the caller must know which groupby type and value are set for this row */
|
2015-03-04 12:03:35 +01:00
|
|
|
if (!addRowFn(service, LivestatusGroupByServiceGroup, sg))
|
|
|
|
return;
|
2015-02-13 15:50:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (GetGroupByType() == LivestatusGroupByHostGroup) {
|
2015-08-15 20:28:05 +02:00
|
|
|
BOOST_FOREACH(const HostGroup::Ptr& hg, ConfigType::GetObjectsByType<HostGroup>()) {
|
2015-02-13 15:50:20 +01:00
|
|
|
ObjectLock ylock(hg);
|
|
|
|
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
|
|
|
|
ObjectLock ylock(host);
|
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
|
|
|
/* the caller must know which groupby type and value are set for this row */
|
2015-03-04 12:03:35 +01:00
|
|
|
if (!addRowFn(service, LivestatusGroupByHostGroup, hg))
|
|
|
|
return;
|
2015-02-13 15:50:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2015-08-15 20:28:05 +02:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, ConfigType::GetObjectsByType<Service>()) {
|
2015-03-04 12:03:35 +01:00
|
|
|
if (!addRowFn(service, LivestatusGroupByNone, Empty))
|
|
|
|
return;
|
2015-02-13 15:50:20 +01:00
|
|
|
}
|
2013-03-10 22:20:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 16:11:40 +02:00
|
|
|
Object::Ptr ServicesTable::HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor)
|
2013-03-10 22:20:13 +01:00
|
|
|
{
|
2013-07-11 08:40:02 +02:00
|
|
|
Value service;
|
|
|
|
|
|
|
|
if (parentObjectAccessor)
|
2015-02-13 15:50:20 +01:00
|
|
|
service = parentObjectAccessor(row, LivestatusGroupByNone, Empty);
|
2013-07-11 08:40:02 +02:00
|
|
|
else
|
|
|
|
service = row;
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr svc = static_cast<Service::Ptr>(service);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!svc)
|
|
|
|
return Object::Ptr();
|
2013-07-11 08:40:02 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return svc->GetHost();
|
2013-03-10 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2015-02-13 15:50:20 +01:00
|
|
|
Object::Ptr ServicesTable::ServiceGroupAccessor(const Value& row, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject)
|
|
|
|
{
|
|
|
|
/* return the current group by value set from within FetchRows()
|
|
|
|
* this is the servicegroup object used for the table join inside
|
|
|
|
* in AddColumns()
|
|
|
|
*/
|
|
|
|
if (groupByType == LivestatusGroupByServiceGroup)
|
|
|
|
return groupByObject;
|
|
|
|
|
|
|
|
return Object::Ptr();
|
|
|
|
}
|
|
|
|
|
|
|
|
Object::Ptr ServicesTable::HostGroupAccessor(const Value& row, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject)
|
|
|
|
{
|
|
|
|
/* return the current group by value set from within FetchRows()
|
|
|
|
* this is the servicegroup object used for the table join inside
|
|
|
|
* in AddColumns()
|
|
|
|
*/
|
|
|
|
if (groupByType == LivestatusGroupByHostGroup)
|
|
|
|
return groupByObject;
|
|
|
|
|
|
|
|
return Object::Ptr();
|
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ShortNameAccessor(const Value& row)
|
2013-03-10 22:20:13 +01:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetShortName();
|
2013-03-10 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::DisplayNameAccessor(const Value& row)
|
2013-03-10 22:20:13 +01:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetDisplayName();
|
2013-03-10 22:20:13 +01:00
|
|
|
}
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckCommandAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
2013-07-08 17:09:15 +02:00
|
|
|
|
|
|
|
if (checkcommand)
|
2014-05-12 14:30:15 +02:00
|
|
|
return CompatUtility::GetCommandName(checkcommand) + "!" + CompatUtility::GetCheckableCommandArgs(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckCommandExpandedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-12-11 10:18:23 +01:00
|
|
|
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-12-11 10:18:23 +01:00
|
|
|
if (checkcommand)
|
2014-05-12 14:30:15 +02:00
|
|
|
return CompatUtility::GetCommandName(checkcommand) + "!" + CompatUtility::GetCheckableCommandArgs(service);
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2013-12-11 10:18:23 +01:00
|
|
|
return Empty;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::EventHandlerAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
EventCommand::Ptr eventcommand = service->GetEventCommand();
|
2013-07-08 17:09:15 +02:00
|
|
|
|
|
|
|
if (eventcommand)
|
2014-05-12 14:30:15 +02:00
|
|
|
return CompatUtility::GetCommandName(eventcommand);
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::PluginOutputAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
String output;
|
2013-11-09 14:22:38 +01:00
|
|
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (cr)
|
|
|
|
output = CompatUtility::GetCheckResultOutput(cr);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
|
|
|
return output;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LongPluginOutputAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
String long_output;
|
2013-11-09 14:22:38 +01:00
|
|
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (cr)
|
|
|
|
long_output = CompatUtility::GetCheckResultLongOutput(cr);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
|
|
|
return long_output;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::PerfDataAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
String perfdata;
|
2013-11-09 14:22:38 +01:00
|
|
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
2013-10-31 14:18:20 +01:00
|
|
|
|
|
|
|
if (cr)
|
|
|
|
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
|
|
|
|
|
|
|
return perfdata;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NotificationPeriodAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNotificationPeriod(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckPeriodAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableCheckPeriod(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NotesAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return service->GetNotes();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NotesExpandedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
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()));
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NotesUrlAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return service->GetNotesUrl();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
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()));
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ActionUrlAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return service->GetActionUrl();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
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()));
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::IconImageAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return service->GetIconImage();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::IconImageExpandedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
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()));
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::IconImageAltAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return service->GetIconImageAlt();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetMaxCheckAttempts();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CurrentAttemptAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetCheckAttempt();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::StateAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return service->GetState();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableHasBeenChecked(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastStateAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetLastState();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastHardStateAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetLastHardState();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::StateTypeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetStateType();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckTypeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableCheckType(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::AcknowledgedAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-10 14:06:46 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-27 13:29:18 +02:00
|
|
|
ObjectLock olock(service);
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableIsAcknowledged(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-10 14:06:46 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-08 17:09:15 +02:00
|
|
|
ObjectLock olock(service);
|
2014-04-27 13:29:18 +02:00
|
|
|
return CompatUtility::GetCheckableAcknowledgementType(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
return CompatUtility::GetCheckableNoMoreNotifications(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastStateOK());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastTimeWarningAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastStateWarning());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastTimeCriticalAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastStateCritical());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastTimeUnknownAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastStateUnknown());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastCheckAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastCheck());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NextCheckAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetNextCheck());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastNotificationAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationLastNotification(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NextNotificationAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNextNotification(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-18 17:24:14 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNotificationNumber(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastStateChangeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastStateChange());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LastHardStateChangeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return static_cast<int>(service->GetLastHardStateChange());
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ScheduledDowntimeDepthAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetDowntimeDepth();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::IsFlappingAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->IsFlapping();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ChecksEnabledAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableActiveChecksEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckablePassiveChecksEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableEventHandlerEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 18:58:48 +02:00
|
|
|
Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationsEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2014-03-12 15:21:56 +01:00
|
|
|
Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return CompatUtility::GetCheckableProcessPerformanceData(service);
|
2014-03-12 15:21:56 +01:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableActiveChecksEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckOptionsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
|
|
|
/* TODO - forcexec, freshness, orphan, none */
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableFlapDetectionEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-12-05 14:54:16 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableFreshnessChecksEnabled(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ModifiedAttributesAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return service->GetModifiedAttributes();
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ModifiedAttributesListAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2014-04-17 16:01:44 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return CompatUtility::GetModifiedAttributesList(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-19 14:19:09 +02:00
|
|
|
Value ServicesTable::StalenessAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableStaleness(service);
|
2013-07-19 14:19:09 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CheckIntervalAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableCheckInterval(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::RetryIntervalAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableRetryInterval(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::NotificationIntervalAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-07-16 17:58:23 +02:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNotificationInterval(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableLowFlapThreshold(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableHighFlapThreshold(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::LatencyAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return (Service::CalculateLatency(service->GetLastCheckResult()));
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ExecutionTimeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return (Service::CalculateExecutionTime(service->GetLastCheckResult()));
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::PercentStateChangeAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckablePercentStateChange(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::InCheckPeriodAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableInCheckPeriod(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableInNotificationPeriod(service);
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ContactsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr contact_names = new Array();
|
2013-10-01 16:32:29 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) {
|
2013-10-01 16:32:29 +02:00
|
|
|
contact_names->Add(user->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
return contact_names;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::DowntimesAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr downtimes = service->GetDowntimes();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
ObjectLock olock(downtimes);
|
|
|
|
|
|
|
|
String id;
|
2013-11-09 22:08:26 +01:00
|
|
|
Downtime::Ptr downtime;
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(tie(id, downtime), downtimes) {
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
if (!downtime)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (downtime->IsExpired())
|
2013-07-16 17:58:23 +02:00
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:08:26 +01:00
|
|
|
ids->Add(downtime->GetLegacyId());
|
2013-07-16 17:58:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::DowntimesWithInfoAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr downtimes = service->GetDowntimes();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
ObjectLock olock(downtimes);
|
|
|
|
|
|
|
|
String id;
|
2013-11-09 22:08:26 +01:00
|
|
|
Downtime::Ptr downtime;
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(tie(id, downtime), downtimes) {
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
if (!downtime)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (downtime->IsExpired())
|
2013-07-16 17:58:23 +02:00
|
|
|
continue;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr downtime_info = new Array();
|
2013-11-09 22:08:26 +01:00
|
|
|
downtime_info->Add(downtime->GetLegacyId());
|
|
|
|
downtime_info->Add(downtime->GetAuthor());
|
|
|
|
downtime_info->Add(downtime->GetComment());
|
2013-07-16 17:58:23 +02:00
|
|
|
ids->Add(downtime_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CommentsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr comments = service->GetComments();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
ObjectLock olock(comments);
|
|
|
|
|
|
|
|
String id;
|
2013-11-09 21:19:52 +01:00
|
|
|
Comment::Ptr comment;
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(tie(id, comment), comments) {
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
if (!comment)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (comment->IsExpired())
|
2013-07-16 17:58:23 +02:00
|
|
|
continue;
|
|
|
|
|
2013-11-09 21:19:52 +01:00
|
|
|
ids->Add(comment->GetLegacyId());
|
2013-07-16 17:58:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CommentsWithInfoAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr comments = service->GetComments();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
ObjectLock olock(comments);
|
|
|
|
|
|
|
|
String id;
|
2013-11-09 21:19:52 +01:00
|
|
|
Comment::Ptr comment;
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(tie(id, comment), comments) {
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
if (!comment)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (comment->IsExpired())
|
2013-07-16 17:58:23 +02:00
|
|
|
continue;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr comment_info = new Array();
|
2013-11-09 21:19:52 +01:00
|
|
|
comment_info->Add(comment->GetLegacyId());
|
|
|
|
comment_info->Add(comment->GetAuthor());
|
|
|
|
comment_info->Add(comment->GetText());
|
2013-07-16 17:58:23 +02:00
|
|
|
ids->Add(comment_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CommentsWithExtraInfoAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr comments = service->GetComments();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
ObjectLock olock(comments);
|
|
|
|
|
|
|
|
String id;
|
2013-11-09 21:19:52 +01:00
|
|
|
Comment::Ptr comment;
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(tie(id, comment), comments) {
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
if (!comment)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (comment->IsExpired())
|
2013-07-16 17:58:23 +02:00
|
|
|
continue;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr comment_info = new Array();
|
2013-11-09 21:19:52 +01:00
|
|
|
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()));
|
2013-07-16 17:58:23 +02:00
|
|
|
ids->Add(comment_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CustomVariableNamesAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
Dictionary::Ptr vars;
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(service);
|
2014-04-03 10:30:11 +02:00
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
2013-10-31 14:18:20 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
if (!vars)
|
2013-07-16 17:58:23 +02:00
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr cv = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-04-27 13:29:18 +02:00
|
|
|
ObjectLock olock(vars);
|
2014-11-04 16:44:45 +01:00
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
|
|
|
cv->Add(kv.first);
|
2013-07-16 17:58:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return cv;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CustomVariableValuesAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
Dictionary::Ptr vars;
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(service);
|
2014-04-03 10:30:11 +02:00
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
2013-10-31 14:18:20 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
if (!vars)
|
2013-07-16 17:58:23 +02:00
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr cv = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-04-27 13:29:18 +02:00
|
|
|
ObjectLock olock(vars);
|
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
2014-11-04 16:44:45 +01:00
|
|
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
|
|
|
cv->Add(JsonEncode(kv.second));
|
|
|
|
else
|
|
|
|
cv->Add(kv.second);
|
2013-07-16 17:58:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return cv;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::CustomVariablesAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
Dictionary::Ptr vars;
|
2013-07-09 17:15:38 +02:00
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(service);
|
2014-04-03 10:30:11 +02:00
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
2013-10-31 14:18:20 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
if (!vars)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-09 17:15:38 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr cv = new Array();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
2014-11-04 16:44:45 +01:00
|
|
|
ObjectLock olock(vars);
|
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr key_val = new Array();
|
2014-11-04 16:44:45 +01:00
|
|
|
key_val->Add(kv.first);
|
|
|
|
|
|
|
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
|
|
|
key_val->Add(JsonEncode(kv.second));
|
|
|
|
else
|
|
|
|
key_val->Add(kv.second);
|
|
|
|
|
2013-07-16 17:58:23 +02:00
|
|
|
cv->Add(key_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cv;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2014-11-04 16:44:45 +01:00
|
|
|
Value ServicesTable::CVIsJsonAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr vars;
|
|
|
|
|
|
|
|
{
|
|
|
|
ObjectLock olock(service);
|
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!vars)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
bool cv_is_json = false;
|
|
|
|
|
|
|
|
ObjectLock olock(vars);
|
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
|
|
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
|
|
|
cv_is_json = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cv_is_json;
|
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::GroupsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Array::Ptr groups = service->GetGroups();
|
2013-07-16 17:58:23 +02:00
|
|
|
|
|
|
|
if (!groups)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return groups;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value ServicesTable::ContactGroupsAccessor(const Value& row)
|
2013-07-08 17:09:15 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr contactgroup_names = new Array();
|
2013-10-01 16:32:29 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) {
|
2013-10-01 16:32:29 +02:00
|
|
|
contactgroup_names->Add(usergroup->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
return contactgroup_names;
|
2013-07-08 17:09:15 +02:00
|
|
|
}
|
|
|
|
|
2014-03-20 19:15:19 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-05-10 20:37:09 +02:00
|
|
|
Value ServicesTable::IsReachableAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
return Empty;
|
2013-07-08 17:09:15 +02:00
|
|
|
|
2014-05-10 20:37:09 +02:00
|
|
|
return service->IsReachable();
|
|
|
|
}
|