/******************************************************************************
* Icinga 2 *
- * Copyright (C) 2012-present Icinga Development Team (http://www.icinga.org) *
+ * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
#include "livestatus/servicestable.h"
#include "livestatus/hoststable.h"
+#include "livestatus/endpointstable.h"
#include "icinga/service.h"
#include "icinga/checkcommand.h"
#include "icinga/eventcommand.h"
table->AddColumn(prefix + "accept_passive_checks", Column(&ServicesTable::AcceptPassiveChecksAccessor, objectAccessor));
table->AddColumn(prefix + "event_handler_enabled", Column(&ServicesTable::EventHandlerEnabledAccessor, objectAccessor));
table->AddColumn(prefix + "notifications_enabled", Column(&ServicesTable::NotificationsEnabledAccessor, objectAccessor));
- table->AddColumn(prefix + "process_performance_data", Column(&Table::OneAccessor, objectAccessor));
+ table->AddColumn(prefix + "process_performance_data", Column(&ServicesTable::ProcessPerformanceDataAccessor, objectAccessor));
table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor));
table->AddColumn(prefix + "active_checks_enabled", Column(&ServicesTable::ActiveChecksEnabledAccessor, objectAccessor));
table->AddColumn(prefix + "check_options", Column(&ServicesTable::CheckOptionsAccessor, objectAccessor));
table->AddColumn(prefix + "custom_variables", Column(&ServicesTable::CustomVariablesAccessor, objectAccessor));
table->AddColumn(prefix + "groups", Column(&ServicesTable::GroupsAccessor, objectAccessor));
table->AddColumn(prefix + "contact_groups", Column(&ServicesTable::ContactGroupsAccessor, objectAccessor));
+ table->AddColumn(prefix + "check_source", Column(&ServicesTable::CheckSourceAccessor, objectAccessor));
HostsTable::AddColumns(table, "host_", boost::bind(&ServicesTable::HostAccessor, _1, objectAccessor));
}
if (!service)
return Empty;
- return CompatUtility::GetServiceNotificationNotificationPeriod(service);
+ return CompatUtility::GetCheckableNotificationNotificationPeriod(service);
}
Value ServicesTable::CheckPeriodAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceCheckPeriod(service);
+ return CompatUtility::GetCheckableCheckPeriod(service);
}
Value ServicesTable::NotesAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetCustomAttributeConfig(service, "notes");
+ return service->GetNotes();
}
Value ServicesTable::NotesExpandedAccessor(const Value& row)
if (!service)
return Empty;
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- Value value = CompatUtility::GetCustomAttributeConfig(service, "notes");
-
- return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+ return MacroProcessor::ResolveMacros(service->GetNotes(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::NotesUrlAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetCustomAttributeConfig(service, "notes_url");
+ return service->GetNotesUrl();
}
Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
if (!service)
return Empty;
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
-
- Value value = CompatUtility::GetCustomAttributeConfig(service, "notes_url");
+ 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()));
- return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+ return MacroProcessor::ResolveMacros(service->GetNotesUrl(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::ActionUrlAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetCustomAttributeConfig(service, "action_url");
+ return service->GetActionUrl();
}
Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
if (!service)
return Empty;
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- Value value = CompatUtility::GetCustomAttributeConfig(service, "action_url");
-
- return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+ return MacroProcessor::ResolveMacros(service->GetActionUrl(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::IconImageAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetCustomAttributeConfig(service, "icon_image");
+ return service->GetIconImage();
}
Value ServicesTable::IconImageExpandedAccessor(const Value& row)
if (!service)
return Empty;
- std::vector<MacroResolver::Ptr> resolvers;
- resolvers.push_back(service);
- resolvers.push_back(service->GetHost());
- resolvers.push_back(IcingaApplication::GetInstance());
-
- Value value = CompatUtility::GetCustomAttributeConfig(service, "icon_image");
+ MacroProcessor::ResolverList resolvers;
+ resolvers.push_back(std::make_pair("service", service));
+ resolvers.push_back(std::make_pair("host", service->GetHost()));
+ resolvers.push_back(std::make_pair("icinga", IcingaApplication::GetInstance()));
- return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
+ return MacroProcessor::ResolveMacros(service->GetIconImage(), resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
}
Value ServicesTable::IconImageAltAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetCustomAttributeConfig(service, "icon_image_alt");
+ return service->GetIconImageAlt();
}
Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceCurrentState(service);
+ return service->GetState();
}
Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceHasBeenChecked(service);
+ return CompatUtility::GetCheckableHasBeenChecked(service);
}
Value ServicesTable::LastStateAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceCheckType(service);
+ return CompatUtility::GetCheckableCheckType(service);
}
Value ServicesTable::AcknowledgedAccessor(const Value& row)
if (!service)
return Empty;
-
- return CompatUtility::GetServiceIsAcknowledged(service);
+ return CompatUtility::GetCheckableIsAcknowledged(service);
}
Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceNoMoreNotifications(service);
+ return CompatUtility::GetCheckableNoMoreNotifications(service);
}
Value ServicesTable::LastTimeOkAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceNotificationLastNotification(service);
+ return CompatUtility::GetCheckableNotificationLastNotification(service);
}
Value ServicesTable::NextNotificationAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceNotificationNextNotification(service);
+ return CompatUtility::GetCheckableNotificationNextNotification(service);
}
Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceNotificationNotificationNumber(service);
+ return CompatUtility::GetCheckableNotificationNotificationNumber(service);
}
Value ServicesTable::LastStateChangeAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceActiveChecksEnabled(service);
+ return CompatUtility::GetCheckableActiveChecksEnabled(service);
}
Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServicePassiveChecksEnabled(service);
+ return CompatUtility::GetCheckablePassiveChecksEnabled(service);
}
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceEventHandlerEnabled(service);
+ return CompatUtility::GetCheckableEventHandlerEnabled(service);
}
Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceNotificationsEnabled(service);
+ return CompatUtility::GetCheckableNotificationsEnabled(service);
+}
+
+Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row)
+{
+ Service::Ptr service = static_cast<Service::Ptr>(row);
+
+ if (!service)
+ return Empty;
+
+ return CompatUtility::GetCheckableProcessPerformanceData(service);
}
Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceActiveChecksEnabled(service);
+ return CompatUtility::GetCheckableActiveChecksEnabled(service);
}
Value ServicesTable::CheckOptionsAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceFlapDetectionEnabled(service);
+ return CompatUtility::GetCheckableFlapDetectionEnabled(service);
}
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceFreshnessChecksEnabled(service);
+ return CompatUtility::GetCheckableFreshnessChecksEnabled(service);
}
Value ServicesTable::ModifiedAttributesAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceStaleness(service);
+ return CompatUtility::GetCheckableStaleness(service);
}
Value ServicesTable::CheckIntervalAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceCheckInterval(service);
+ return CompatUtility::GetCheckableCheckInterval(service);
}
Value ServicesTable::RetryIntervalAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceRetryInterval(service);
+ return CompatUtility::GetCheckableRetryInterval(service);
}
Value ServicesTable::NotificationIntervalAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceNotificationNotificationInterval(service);
+ return CompatUtility::GetCheckableNotificationNotificationInterval(service);
}
Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceLowFlapThreshold(service);
+ return CompatUtility::GetCheckableLowFlapThreshold(service);
}
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceHighFlapThreshold(service);
+ return CompatUtility::GetCheckableHighFlapThreshold(service);
}
Value ServicesTable::LatencyAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServicePercentStateChange(service);
+ return CompatUtility::GetCheckablePercentStateChange(service);
}
Value ServicesTable::InCheckPeriodAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceInCheckPeriod(service);
+ return CompatUtility::GetCheckableInCheckPeriod(service);
}
Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
if (!service)
return Empty;
- return CompatUtility::GetServiceInNotificationPeriod(service);
+ return CompatUtility::GetCheckableInNotificationPeriod(service);
}
Value ServicesTable::ContactsAccessor(const Value& row)
Array::Ptr contact_names = make_shared<Array>();
- BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetServiceNotificationUsers(service)) {
+ BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) {
contact_names->Add(user->GetName());
}
String id;
Downtime::Ptr downtime;
- BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+ BOOST_FOREACH(tie(id, downtime), downtimes) {
if (!downtime)
continue;
String id;
Downtime::Ptr downtime;
- BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
+ BOOST_FOREACH(tie(id, downtime), downtimes) {
if (!downtime)
continue;
String id;
Comment::Ptr comment;
- BOOST_FOREACH(boost::tie(id, comment), comments) {
+ BOOST_FOREACH(tie(id, comment), comments) {
if (!comment)
continue;
String id;
Comment::Ptr comment;
- BOOST_FOREACH(boost::tie(id, comment), comments) {
+ BOOST_FOREACH(tie(id, comment), comments) {
if (!comment)
continue;
String id;
Comment::Ptr comment;
- BOOST_FOREACH(boost::tie(id, comment), comments) {
+ BOOST_FOREACH(tie(id, comment), comments) {
if (!comment)
continue;
if (!service)
return Empty;
- Dictionary::Ptr customvars;
+ Dictionary::Ptr vars;
{
ObjectLock olock(service);
- customvars = CompatUtility::GetCustomVariableConfig(service);
+ vars = CompatUtility::GetCustomAttributeConfig(service);
}
- if (!customvars)
+ if (!vars)
return Empty;
Array::Ptr cv = make_shared<Array>();
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), customvars) {
+ BOOST_FOREACH(tie(key, value), vars) {
cv->Add(key);
}
if (!service)
return Empty;
- Dictionary::Ptr customvars;
+ Dictionary::Ptr vars;
{
ObjectLock olock(service);
- customvars = CompatUtility::GetCustomVariableConfig(service);
+ vars = CompatUtility::GetCustomAttributeConfig(service);
}
- if (!customvars)
+ if (!vars)
return Empty;
Array::Ptr cv = make_shared<Array>();
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), customvars) {
+ BOOST_FOREACH(tie(key, value), vars) {
cv->Add(value);
}
if (!service)
return Empty;
- Dictionary::Ptr customvars;
+ Dictionary::Ptr vars;
{
ObjectLock olock(service);
- customvars = CompatUtility::GetCustomVariableConfig(service);
+ vars = CompatUtility::GetCustomAttributeConfig(service);
}
- if (!customvars)
+ if (!vars)
return Empty;
Array::Ptr cv = make_shared<Array>();
String key;
Value value;
- BOOST_FOREACH(boost::tie(key, value), customvars) {
+ BOOST_FOREACH(tie(key, value), vars) {
Array::Ptr key_val = make_shared<Array>();
key_val->Add(key);
key_val->Add(value);
Array::Ptr contactgroup_names = make_shared<Array>();
- BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetServiceNotificationUserGroups(service)) {
+ BOOST_FOREACH(const UserGroup::Ptr& usergroup, CompatUtility::GetCheckableNotificationUserGroups(service)) {
contactgroup_names->Add(usergroup->GetName());
}
return contactgroup_names;
}
+Value ServicesTable::CheckSourceAccessor(const Value& row)
+{
+ Service::Ptr service = static_cast<Service::Ptr>(row);
+
+ if (!service)
+ return Empty;
+
+ CheckResult::Ptr cr = service->GetLastCheckResult();
+
+ if (cr)
+ return cr->GetCheckSource();
+
+ return Empty;
+}
+