2013-03-10 18:49:14 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2014-03-19 01:02:29 +01:00
|
|
|
* Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
|
2013-03-10 18:49:14 +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/hoststable.hpp"
|
|
|
|
#include "icinga/host.hpp"
|
|
|
|
#include "icinga/service.hpp"
|
|
|
|
#include "icinga/checkcommand.hpp"
|
|
|
|
#include "icinga/eventcommand.hpp"
|
|
|
|
#include "icinga/timeperiod.hpp"
|
|
|
|
#include "icinga/macroprocessor.hpp"
|
|
|
|
#include "icinga/icingaapplication.hpp"
|
|
|
|
#include "icinga/compatutility.hpp"
|
|
|
|
#include "base/dynamictype.hpp"
|
|
|
|
#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-07-19 13:59:39 +02:00
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
2013-03-16 21:18:53 +01:00
|
|
|
#include <boost/foreach.hpp>
|
2013-07-17 16:10:10 +02:00
|
|
|
#include <boost/tuple/tuple.hpp>
|
2013-07-30 22:38:33 +02:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
2013-07-19 13:59:39 +02:00
|
|
|
#include <boost/algorithm/string/split.hpp>
|
2013-03-10 18:49:14 +01:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
|
|
|
HostsTable::HostsTable(void)
|
|
|
|
{
|
|
|
|
AddColumns(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HostsTable::AddColumns(Table *table, const String& prefix,
|
|
|
|
const Column::ObjectAccessor& objectAccessor)
|
|
|
|
{
|
|
|
|
table->AddColumn(prefix + "name", Column(&HostsTable::NameAccessor, objectAccessor));
|
2014-06-12 11:59:21 +02:00
|
|
|
table->AddColumn(prefix + "host_name", Column(&HostsTable::NameAccessor, objectAccessor)); //ugly compatibility hack
|
2013-03-10 18:49:14 +01:00
|
|
|
table->AddColumn(prefix + "display_name", Column(&HostsTable::DisplayNameAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "alias", Column(&HostsTable::DisplayNameAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "address", Column(&HostsTable::AddressAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "address6", Column(&HostsTable::Address6Accessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_command", Column(&HostsTable::CheckCommandAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_command_expanded", Column(&HostsTable::CheckCommandExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "event_handler", Column(&HostsTable::EventHandlerAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notification_period", Column(&HostsTable::NotificationPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_period", Column(&HostsTable::CheckPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes", Column(&HostsTable::NotesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_expanded", Column(&HostsTable::NotesExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_url", Column(&HostsTable::NotesUrlAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notes_url_expanded", Column(&HostsTable::NotesUrlExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "action_url", Column(&HostsTable::ActionUrlAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "action_url_expanded", Column(&HostsTable::ActionUrlExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "plugin_output", Column(&HostsTable::PluginOutputAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "perf_data", Column(&HostsTable::PerfDataAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "icon_image", Column(&HostsTable::IconImageAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "icon_image_expanded", Column(&HostsTable::IconImageExpandedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "icon_image_alt", Column(&HostsTable::IconImageAltAccessor, objectAccessor));
|
2014-04-22 13:48:06 +02:00
|
|
|
table->AddColumn(prefix + "statusmap_image", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "long_plugin_output", Column(&HostsTable::LongPluginOutputAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "initial_state", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "max_check_attempts", Column(&HostsTable::MaxCheckAttemptsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "flap_detection_enabled", Column(&HostsTable::FlapDetectionEnabledAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "check_freshness", Column(&Table::OneAccessor, objectAccessor));
|
2014-03-12 15:21:56 +01:00
|
|
|
table->AddColumn(prefix + "process_performance_data", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "accept_passive_checks", Column(&HostsTable::AcceptPassiveChecksAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "event_handler_enabled", Column(&HostsTable::EventHandlerEnabledAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "acknowledgement_type", Column(&HostsTable::AcknowledgementTypeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_type", Column(&HostsTable::CheckTypeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_state", Column(&HostsTable::LastStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_hard_state", Column(&HostsTable::LastHardStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "current_attempt", Column(&HostsTable::CurrentAttemptAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_notification", Column(&HostsTable::LastNotificationAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "next_notification", Column(&HostsTable::NextNotificationAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "next_check", Column(&HostsTable::NextCheckAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_hard_state_change", Column(&HostsTable::LastHardStateChangeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "has_been_checked", Column(&HostsTable::HasBeenCheckedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "current_notification_number", Column(&HostsTable::CurrentNotificationNumberAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "pending_flex_downtime", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "total_services", Column(&HostsTable::TotalServicesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "checks_enabled", Column(&HostsTable::ChecksEnabledAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notifications_enabled", Column(&HostsTable::NotificationsEnabledAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "acknowledged", Column(&HostsTable::AcknowledgedAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "state", Column(&HostsTable::StateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "state_type", Column(&HostsTable::StateTypeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "no_more_notifications", Column(&HostsTable::NoMoreNotificationsAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "check_flapping_recovery_notification", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "last_check", Column(&HostsTable::LastCheckAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_state_change", Column(&HostsTable::LastStateChangeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_up", Column(&HostsTable::LastTimeUpAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_down", Column(&HostsTable::LastTimeDownAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "last_time_unreachable", Column(&HostsTable::LastTimeUnreachableAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "is_flapping", Column(&HostsTable::IsFlappingAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "scheduled_downtime_depth", Column(&HostsTable::ScheduledDowntimeDepthAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "active_checks_enabled", Column(&HostsTable::ActiveChecksEnabledAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_options", Column(&HostsTable::CheckOptionsAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "obsess_over_host", Column(&Table::ZeroAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "modified_attributes", Column(&HostsTable::ModifiedAttributesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "modified_attributes_list", Column(&HostsTable::ModifiedAttributesListAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "check_interval", Column(&HostsTable::CheckIntervalAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "retry_interval", Column(&HostsTable::RetryIntervalAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "notification_interval", Column(&HostsTable::NotificationIntervalAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "first_notification_delay", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "low_flap_threshold", Column(&HostsTable::LowFlapThresholdAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "high_flap_threshold", Column(&HostsTable::HighFlapThresholdAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "x_3d", Column(&EmptyStringAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "y_3d", Column(&EmptyStringAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "z_3d", Column(&EmptyStringAccessor, objectAccessor));
|
2014-04-22 13:48:06 +02:00
|
|
|
table->AddColumn(prefix + "x_2d", Column(&Table::EmptyStringAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "y_2d", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "latency", Column(&HostsTable::LatencyAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "execution_time", Column(&HostsTable::ExecutionTimeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "percent_state_change", Column(&HostsTable::PercentStateChangeAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "in_notification_period", Column(&HostsTable::InNotificationPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "in_check_period", Column(&HostsTable::InCheckPeriodAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "contacts", Column(&HostsTable::ContactsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "downtimes", Column(&HostsTable::DowntimesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "downtimes_with_info", Column(&HostsTable::DowntimesWithInfoAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "comments", Column(&HostsTable::CommentsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "comments_with_info", Column(&HostsTable::CommentsWithInfoAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "comments_with_extra_info", Column(&HostsTable::CommentsWithExtraInfoAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "custom_variable_names", Column(&HostsTable::CustomVariableNamesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "custom_variable_values", Column(&HostsTable::CustomVariableValuesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "custom_variables", Column(&HostsTable::CustomVariablesAccessor, objectAccessor));
|
2013-10-03 18:58:48 +02:00
|
|
|
table->AddColumn(prefix + "filename", Column(&Table::EmptyStringAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "parents", Column(&HostsTable::ParentsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "childs", Column(&HostsTable::ChildsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services", Column(&HostsTable::NumServicesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "worst_service_state", Column(&HostsTable::WorstServiceStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_ok", Column(&HostsTable::NumServicesOkAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_warn", Column(&HostsTable::NumServicesWarnAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_crit", Column(&HostsTable::NumServicesCritAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_unknown", Column(&HostsTable::NumServicesUnknownAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_pending", Column(&HostsTable::NumServicesPendingAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "worst_service_hard_state", Column(&HostsTable::WorstServiceHardStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_ok", Column(&HostsTable::NumServicesHardOkAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_warn", Column(&HostsTable::NumServicesHardWarnAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_crit", Column(&HostsTable::NumServicesHardCritAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "num_services_hard_unknown", Column(&HostsTable::NumServicesHardUnknownAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "hard_state", Column(&HostsTable::HardStateAccessor, 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(&HostsTable::StalenessAccessor, objectAccessor));
|
2013-07-05 09:35:49 +02:00
|
|
|
table->AddColumn(prefix + "groups", Column(&HostsTable::GroupsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "contact_groups", Column(&HostsTable::ContactGroupsAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "services", Column(&HostsTable::ServicesAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "services_with_state", Column(&HostsTable::ServicesWithStateAccessor, objectAccessor));
|
|
|
|
table->AddColumn(prefix + "services_with_info", Column(&HostsTable::ServicesWithInfoAccessor, objectAccessor));
|
2014-05-10 21:57:01 +02:00
|
|
|
table->AddColumn(prefix + "check_source", Column(&HostsTable::CheckSourceAccessor, objectAccessor));
|
2014-05-10 20:37:09 +02:00
|
|
|
table->AddColumn(prefix + "is_reachable", Column(&HostsTable::IsReachableAccessor, objectAccessor));
|
2014-11-04 16:44:45 +01:00
|
|
|
table->AddColumn(prefix + "cv_is_json", Column(&HostsTable::CVIsJsonAccessor, objectAccessor));
|
2013-03-10 18:49:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
String HostsTable::GetName(void) const
|
|
|
|
{
|
|
|
|
return "hosts";
|
|
|
|
}
|
|
|
|
|
2014-06-25 11:30:27 +02:00
|
|
|
String HostsTable::GetPrefix(void) const
|
|
|
|
{
|
|
|
|
return "host";
|
|
|
|
}
|
|
|
|
|
2013-03-15 18:21:29 +01:00
|
|
|
void HostsTable::FetchRows(const AddRowFunction& addRowFn)
|
2013-03-10 18:49:14 +01:00
|
|
|
{
|
2014-09-02 13:02:22 +02:00
|
|
|
BOOST_FOREACH(const Host::Ptr& host, DynamicType::GetObjectsByType<Host>()) {
|
2013-08-20 11:06:04 +02:00
|
|
|
addRowFn(host);
|
2013-03-10 18:49:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NameAccessor(const Value& row)
|
2013-03-10 18:49:14 +01:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetName();
|
2013-03-10 18:49:14 +01:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::DisplayNameAccessor(const Value& row)
|
2013-03-10 18:49:14 +01:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetDisplayName();
|
2013-03-10 18:49:14 +01:00
|
|
|
}
|
2013-07-05 09:35:49 +02:00
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::AddressAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 13:42:40 +02:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
|
2014-04-08 13:34:48 +02:00
|
|
|
return host->GetAddress();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::Address6Accessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 13:42:40 +02:00
|
|
|
|
2014-04-08 13:34:48 +02:00
|
|
|
return host->GetAddress6();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CheckCommandAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
CheckCommand::Ptr checkcommand = host->GetCheckCommand();
|
2013-07-05 09:35:49 +02:00
|
|
|
if (checkcommand)
|
2014-05-12 14:30:15 +02:00
|
|
|
return CompatUtility::GetCommandName(checkcommand) + "!" + CompatUtility::GetCheckableCommandArgs(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CheckCommandExpandedAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-07-17 16:38:31 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
CheckCommand::Ptr checkcommand = host->GetCheckCommand();
|
2013-12-11 10:18:23 +01:00
|
|
|
if (checkcommand)
|
2014-05-12 14:30:15 +02:00
|
|
|
return CompatUtility::GetCommandName(checkcommand) + "!" + CompatUtility::GetCheckableCommandArgs(host);
|
2013-07-17 16:38:31 +02:00
|
|
|
|
2013-12-11 10:18:23 +01:00
|
|
|
return Empty;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::EventHandlerAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
EventCommand::Ptr eventcommand = host->GetEventCommand();
|
2013-07-05 09:35:49 +02:00
|
|
|
if (eventcommand)
|
2014-05-12 14:30:15 +02:00
|
|
|
return CompatUtility::GetCommandName(eventcommand);
|
2013-07-05 09:35:49 +02:00
|
|
|
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotificationPeriodAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNotificationPeriod(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CheckPeriodAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 09:35:49 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableCheckPeriod(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 11:32:19 +02:00
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return host->GetNotes();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotesExpandedAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-07-17 16:10:10 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-29 13:44:43 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-10-29 13:44:43 +01:00
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
MacroProcessor::ResolverList resolvers;
|
|
|
|
resolvers.push_back(std::make_pair("host", host));
|
|
|
|
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(host->GetNotes(), resolvers, CheckResult::Ptr());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotesUrlAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return host->GetNotesUrl();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotesUrlExpandedAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-07-17 16:10:10 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-10-29 13:44:43 +01:00
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
MacroProcessor::ResolverList resolvers;
|
|
|
|
resolvers.push_back(std::make_pair("host", host));
|
|
|
|
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(host->GetNotesUrl(), resolvers);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ActionUrlAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 11:32:19 +02:00
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return host->GetActionUrl();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ActionUrlExpandedAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-07-17 16:10:10 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-10-29 13:44:43 +01:00
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
MacroProcessor::ResolverList resolvers;
|
|
|
|
resolvers.push_back(std::make_pair("host", host));
|
|
|
|
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(host->GetActionUrl(), resolvers);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::PluginOutputAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-05 09:35:49 +02:00
|
|
|
String output;
|
2014-04-03 15:36:13 +02:00
|
|
|
CheckResult::Ptr cr = host->GetLastCheckResult();
|
2013-07-05 09:35:49 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
if (cr)
|
|
|
|
output = CompatUtility::GetCheckResultOutput(cr);
|
2013-07-05 09:35:49 +02:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
Value HostsTable::PerfDataAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2014-04-17 13:49:45 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
String perfdata;
|
|
|
|
CheckResult::Ptr cr = host->GetLastCheckResult();
|
|
|
|
|
|
|
|
if (cr)
|
|
|
|
perfdata = CompatUtility::GetCheckResultPerfdata(cr);
|
|
|
|
|
|
|
|
return perfdata;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::IconImageAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 11:32:19 +02:00
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return host->GetIconImage();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::IconImageExpandedAccessor(const Value& row)
|
2013-07-05 10:51:09 +02:00
|
|
|
{
|
2013-07-17 16:10:10 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-10-29 13:44:43 +01:00
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 13:23:24 +02:00
|
|
|
MacroProcessor::ResolverList resolvers;
|
|
|
|
resolvers.push_back(std::make_pair("host", host));
|
|
|
|
resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-04-26 13:16:08 +02:00
|
|
|
return MacroProcessor::ResolveMacros(host->GetIconImage(), resolvers);
|
2013-07-05 10:51:09 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::IconImageAltAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 11:32:19 +02:00
|
|
|
|
2014-04-17 13:49:45 +02:00
|
|
|
return host->GetIconImageAlt();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LongPluginOutputAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-05 09:35:49 +02:00
|
|
|
String long_output;
|
2014-04-03 15:36:13 +02:00
|
|
|
CheckResult::Ptr cr = host->GetLastCheckResult();
|
2013-07-05 09:35:49 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
if (cr)
|
|
|
|
long_output = CompatUtility::GetCheckResultLongOutput(cr);
|
2013-07-05 09:35:49 +02:00
|
|
|
|
|
|
|
return long_output;
|
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::MaxCheckAttemptsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return host->GetMaxCheckAttempts();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::FlapDetectionEnabledAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableFlapDetectionEnabled(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::AcceptPassiveChecksAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckablePassiveChecksEnabled(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::EventHandlerEnabledAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableEventHandlerEnabled(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::AcknowledgementTypeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-27 13:29:18 +02:00
|
|
|
ObjectLock olock(host);
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableAcknowledgementType(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CheckTypeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableCheckType(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastStateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetLastState();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastHardStateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetLastHardState();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CurrentAttemptAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return host->GetCheckAttempt();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastNotificationAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationLastNotification(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NextNotificationAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNextNotification(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NextCheckAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return static_cast<int>(host->GetNextCheck());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastHardStateChangeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return static_cast<int>(host->GetLastHardStateChange());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::HasBeenCheckedAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableHasBeenChecked(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CurrentNotificationNumberAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-08-17 17:57:20 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNotificationNumber(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::TotalServicesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetTotalServices();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ChecksEnabledAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableActiveChecksEnabled(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotificationsEnabledAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationsEnabled(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::AcknowledgedAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-27 13:29:18 +02:00
|
|
|
ObjectLock olock(host);
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableIsAcknowledged(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::StateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 08:54:49 +02:00
|
|
|
return host->IsReachable() ? host->GetState() : 2;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::StateTypeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetStateType();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNoMoreNotifications(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastCheckAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return static_cast<int>(host->GetLastCheck());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastStateChangeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return static_cast<int>(host->GetLastStateChange());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastTimeUpAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return static_cast<int>(host->GetLastStateUp());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastTimeDownAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return static_cast<int>(host->GetLastStateDown());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LastTimeUnreachableAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return static_cast<int>(host->GetLastStateUnreachable());
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::IsFlappingAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return host->IsFlapping();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ScheduledDowntimeDepthAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return host->GetDowntimeDepth();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ActiveChecksEnabledAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableActiveChecksEnabled(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2014-05-22 09:02:44 +02:00
|
|
|
Value HostsTable::CheckOptionsAccessor(const Value&)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
|
|
|
/* TODO - forcexec, freshness, orphan, none */
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ModifiedAttributesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return host->GetModifiedAttributes();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ModifiedAttributesListAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2014-04-17 16:01:44 +02:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return CompatUtility::GetModifiedAttributesList(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CheckIntervalAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableCheckInterval(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::RetryIntervalAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableRetryInterval(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NotificationIntervalAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableNotificationNotificationInterval(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LowFlapThresholdAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableLowFlapThreshold(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::HighFlapThresholdAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableHighFlapThreshold(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::LatencyAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return (Service::CalculateLatency(host->GetLastCheckResult()));
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ExecutionTimeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return (Service::CalculateExecutionTime(host->GetLastCheckResult()));
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::PercentStateChangeAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckablePercentStateChange(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::InNotificationPeriodAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableInNotificationPeriod(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::InCheckPeriodAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableInCheckPeriod(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ContactsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
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(host)) {
|
2013-10-01 16:32:29 +02:00
|
|
|
contact_names->Add(user->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
return contact_names;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::DowntimesAccessor(const Value& row)
|
2013-07-05 10:51:09 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
Dictionary::Ptr downtimes = host->GetDowntimes();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
|
|
|
|
if (!downtime)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (downtime->IsExpired())
|
2013-07-17 16:10:10 +02:00
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:08:26 +01:00
|
|
|
ids->Add(downtime->GetLegacyId());
|
2013-07-17 16:10:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-05 10:51:09 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::DowntimesWithInfoAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
Dictionary::Ptr downtimes = host->GetDowntimes();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
|
|
|
|
if (!downtime)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (downtime->IsExpired())
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
ids->Add(downtime_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CommentsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
Dictionary::Ptr comments = host->GetComments();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
|
|
|
|
if (!comment)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (comment->IsExpired())
|
2013-07-17 16:10:10 +02:00
|
|
|
continue;
|
|
|
|
|
2013-11-09 21:19:52 +01:00
|
|
|
ids->Add(comment->GetLegacyId());
|
2013-07-17 16:10:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CommentsWithInfoAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
Dictionary::Ptr comments = host->GetComments();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
|
|
|
|
if (!comment)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (comment->IsExpired())
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
ids->Add(comment_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CommentsWithExtraInfoAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
Dictionary::Ptr comments = host->GetComments();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr ids = new Array();
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
|
|
|
|
if (!comment)
|
|
|
|
continue;
|
|
|
|
|
2013-11-09 22:16:53 +01:00
|
|
|
if (comment->IsExpired())
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
ids->Add(comment_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CustomVariableNamesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
Dictionary::Ptr vars;
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(host);
|
2014-04-03 10:30:11 +02:00
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
2013-10-31 14:18:20 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
if (!vars)
|
2013-07-17 16:10:10 +02:00
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr cv = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-04 16:44:45 +01:00
|
|
|
ObjectLock olock(vars);
|
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
|
|
|
cv->Add(kv.first);
|
2013-07-17 16:10:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return cv;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CustomVariableValuesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
Dictionary::Ptr vars;
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(host);
|
2014-04-03 10:30:11 +02:00
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
2013-10-31 14:18:20 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
if (!vars)
|
2013-07-17 16:10:10 +02:00
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr cv = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-11-04 16:44:45 +01:00
|
|
|
ObjectLock olock(vars);
|
|
|
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
|
|
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
|
|
|
cv->Add(JsonEncode(kv.second));
|
|
|
|
else
|
|
|
|
cv->Add(kv.second);
|
2013-07-17 16:10:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return cv;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::CustomVariablesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
Dictionary::Ptr vars;
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-31 14:18:20 +01:00
|
|
|
{
|
|
|
|
ObjectLock olock(host);
|
2014-04-03 10:30:11 +02:00
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
2013-10-31 14:18:20 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 10:30:11 +02:00
|
|
|
if (!vars)
|
2013-07-17 16:10:10 +02:00
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr cv = new Array();
|
2013-07-17 16:10:10 +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-17 16:10:10 +02:00
|
|
|
cv->Add(key_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cv;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2014-11-04 16:44:45 +01:00
|
|
|
Value HostsTable::CVIsJsonAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
Dictionary::Ptr vars;
|
|
|
|
|
|
|
|
{
|
|
|
|
ObjectLock olock(host);
|
|
|
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 HostsTable::ParentsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr parents = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(const Checkable::Ptr& parent, host->GetParents()) {
|
|
|
|
Host::Ptr parent_host = dynamic_pointer_cast<Host>(parent);
|
|
|
|
|
|
|
|
if (!parent_host)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
parents->Add(parent_host->GetName());
|
2013-07-17 16:10:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parents;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ChildsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr childs = new Array();
|
2013-07-19 16:11:35 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
BOOST_FOREACH(const Checkable::Ptr& child, host->GetChildren()) {
|
|
|
|
Host::Ptr child_host = dynamic_pointer_cast<Host>(child);
|
|
|
|
|
|
|
|
if (!child_host)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
childs->Add(child_host->GetName());
|
2013-07-19 16:11:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return childs;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-07-05 19:14:10 +02:00
|
|
|
/* duplicate of TotalServices */
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
return host->GetTotalServices();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::WorstServiceStateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 09:11:54 +02:00
|
|
|
Value worst_service = ServiceOK;
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2013-07-17 16:10:10 +02:00
|
|
|
if (service->GetState() > worst_service)
|
|
|
|
worst_service = service->GetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
return worst_service;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesOkAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceOK)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesWarnAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceWarning)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesCritAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceCritical)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesUnknownAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetState() == ServiceUnknown)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesPendingAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2013-07-17 16:10:10 +02:00
|
|
|
if (!service->GetLastCheckResult())
|
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::WorstServiceHardStateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-08 09:11:54 +02:00
|
|
|
Value worst_service = ServiceOK;
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2013-07-17 16:10:10 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard) {
|
|
|
|
if (service->GetState() > worst_service)
|
|
|
|
worst_service = service->GetState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return worst_service;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesHardOkAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceOK)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesHardWarnAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceWarning)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesHardCritAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceCritical)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::NumServicesHardUnknownAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
int num_services = 0;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-04-08 09:11:54 +02:00
|
|
|
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceUnknown)
|
2013-07-17 16:10:10 +02:00
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::HardStateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
if (host->GetState() == HostUp)
|
|
|
|
return HostUp;
|
|
|
|
else if (host->GetStateType() == StateTypeHard)
|
|
|
|
return host->GetState();
|
2013-07-05 19:14:10 +02:00
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return host->GetLastHardState();
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::StalenessAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-04-03 15:36:13 +02:00
|
|
|
return CompatUtility::GetCheckableStaleness(host);
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::GroupsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
Array::Ptr groups = host->GetGroups();
|
2013-07-05 19:14:10 +02:00
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
if (!groups)
|
2013-07-12 19:20:12 +02:00
|
|
|
return Empty;
|
2013-07-05 19:14:10 +02:00
|
|
|
|
2013-07-17 16:10:10 +02:00
|
|
|
return groups;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ContactGroupsAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
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(host)) {
|
2013-10-01 16:32:29 +02:00
|
|
|
contactgroup_names->Add(usergroup->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
return contactgroup_names;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ServicesAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr services = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2013-07-17 16:10:10 +02:00
|
|
|
services->Add(service->GetShortName());
|
|
|
|
}
|
|
|
|
|
|
|
|
return services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ServicesWithStateAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr services = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr svc_add = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
|
|
|
svc_add->Add(service->GetShortName());
|
|
|
|
svc_add->Add(service->GetState());
|
|
|
|
svc_add->Add(service->HasBeenChecked() ? 1 : 0);
|
|
|
|
services->Add(svc_add);
|
|
|
|
}
|
|
|
|
|
|
|
|
return services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 14:06:46 +02:00
|
|
|
Value HostsTable::ServicesWithInfoAccessor(const Value& row)
|
2013-07-05 09:35:49 +02:00
|
|
|
{
|
2013-10-29 13:44:43 +01:00
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
2013-10-31 14:18:20 +01:00
|
|
|
|
2013-12-05 14:54:16 +01:00
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr services = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
2013-10-29 13:44:43 +01:00
|
|
|
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
2014-11-08 21:17:16 +01:00
|
|
|
Array::Ptr svc_add = new Array();
|
2013-07-17 16:10:10 +02:00
|
|
|
|
|
|
|
svc_add->Add(service->GetShortName());
|
|
|
|
svc_add->Add(service->GetState());
|
|
|
|
svc_add->Add(service->HasBeenChecked() ? 1 : 0);
|
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
|
|
|
|
|
|
|
svc_add->Add(output);
|
2013-07-17 16:10:10 +02:00
|
|
|
services->Add(svc_add);
|
|
|
|
}
|
|
|
|
|
|
|
|
return services;
|
2013-07-05 09:35:49 +02:00
|
|
|
}
|
2014-05-10 20:37:09 +02:00
|
|
|
|
2014-05-10 21:57:01 +02:00
|
|
|
Value HostsTable::CheckSourceAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
CheckResult::Ptr cr = host->GetLastCheckResult();
|
|
|
|
|
|
|
|
if (cr)
|
|
|
|
return cr->GetCheckSource();
|
|
|
|
|
|
|
|
return Empty;
|
|
|
|
}
|
|
|
|
|
2014-05-10 20:37:09 +02:00
|
|
|
Value HostsTable::IsReachableAccessor(const Value& row)
|
|
|
|
{
|
|
|
|
Host::Ptr host = static_cast<Host::Ptr>(row);
|
|
|
|
|
|
|
|
if (!host)
|
|
|
|
return Empty;
|
|
|
|
|
|
|
|
return host->IsReachable();
|
|
|
|
}
|