From 1279d27720d32a467f12b1fc158b7feaa7e9bbc6 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 12 Mar 2014 15:21:56 +0100 Subject: [PATCH] Fix enable_perfdata attribute in compat features. Fixes #5693 --- components/compat/statusdatawriter.cpp | 4 ++-- components/livestatus/hoststable.cpp | 22 +++------------------- components/livestatus/servicestable.cpp | 12 +++++++++++- components/livestatus/servicestable.h | 1 + components/livestatus/statustable.cpp | 7 ++++++- components/livestatus/statustable.h | 1 + lib/db_ido/dbconnection.cpp | 2 +- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/components/compat/statusdatawriter.cpp b/components/compat/statusdatawriter.cpp index 8c2ba0105..631ae066c 100644 --- a/components/compat/statusdatawriter.cpp +++ b/components/compat/statusdatawriter.cpp @@ -295,7 +295,7 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) fp << "\t" << "initial_state" "\t" "o" "\n" "\t" "low_flap_threshold" "\t" << hc->GetFlappingThreshold() << "\n" "\t" "high_flap_threshold" "\t" << hc->GetFlappingThreshold() << "\n" - "\t" "process_perf_data" "\t" "1" "\n" + "\t" "process_perf_data" "\t" << CompatUtility::GetServiceProcessPerformanceData(hc) << "\n" "\t" "check_freshness" "\t" "1" "\n"; } else { @@ -467,7 +467,7 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s fp << "\t" "initial_state" "\t" "o" "\n" "\t" "low_flap_threshold" "\t" << service->GetFlappingThreshold() << "\n" "\t" "high_flap_threshold" "\t" << service->GetFlappingThreshold() << "\n" - "\t" "process_perf_data" "\t" "1" "\n" + "\t" "process_perf_data" "\t" << CompatUtility::GetServiceProcessPerformanceData(service) << "\n" "\t" "check_freshness" << "\t" "1" "\n"; if (!notes.IsEmpty()) fp << "\t" "notes" "\t" << notes << "\n"; diff --git a/components/livestatus/hoststable.cpp b/components/livestatus/hoststable.cpp index f13b50d37..1f70aa9e2 100644 --- a/components/livestatus/hoststable.cpp +++ b/components/livestatus/hoststable.cpp @@ -73,7 +73,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "max_check_attempts", Column(&HostsTable::MaxCheckAttemptsAccessor, objectAccessor)); table->AddColumn(prefix + "flap_detection_enabled", Column(&HostsTable::FlapDetectionEnabledAccessor, objectAccessor)); table->AddColumn(prefix + "check_freshness", Column(&Table::OneAccessor, objectAccessor)); - table->AddColumn(prefix + "process_performance_data", Column(&Table::OneAccessor, objectAccessor)); + table->AddColumn(prefix + "process_performance_data", Column(&Table::ZeroAccessor, objectAccessor)); 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)); @@ -435,25 +435,9 @@ Value HostsTable::PluginOutputAccessor(const Value& row) return output; } -Value HostsTable::PerfDataAccessor(const Value& row) +Value HostsTable::PerfDataAccessor(const Value&) { - /* use hostcheck service */ - Host::Ptr host = static_cast(row); - - if (!host) - return Empty; - - Service::Ptr hc = host->GetCheckService(); - String perfdata; - - if (hc) { - CheckResult::Ptr cr = hc->GetLastCheckResult(); - - if (cr) - perfdata = CompatUtility::GetCheckResultPerfdata(cr); - } - - return perfdata; + return Empty; } Value HostsTable::IconImageAccessor(const Value& row) diff --git a/components/livestatus/servicestable.cpp b/components/livestatus/servicestable.cpp index df4d95dd6..a2ed4441d 100644 --- a/components/livestatus/servicestable.cpp +++ b/components/livestatus/servicestable.cpp @@ -92,7 +92,7 @@ void ServicesTable::AddColumns(Table *table, const String& prefix, 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)); @@ -693,6 +693,16 @@ Value ServicesTable::NotificationsEnabledAccessor(const Value& row) return CompatUtility::GetServiceNotificationsEnabled(service); } +Value ServicesTable::ProcessPerformanceDataAccessor(const Value& row) +{ + Service::Ptr service = static_cast(row); + + if (!service) + return Empty; + + return CompatUtility::GetServiceProcessPerformanceData(service); +} + Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row) { Service::Ptr service = static_cast(row); diff --git a/components/livestatus/servicestable.h b/components/livestatus/servicestable.h index 29a9c2a29..5f83ff103 100644 --- a/components/livestatus/servicestable.h +++ b/components/livestatus/servicestable.h @@ -94,6 +94,7 @@ protected: static Value AcceptPassiveChecksAccessor(const Value& row); static Value EventHandlerEnabledAccessor(const Value& row); static Value NotificationsEnabledAccessor(const Value& row); + static Value ProcessPerformanceDataAccessor(const Value& row); static Value ActiveChecksEnabledAccessor(const Value& row); static Value CheckOptionsAccessor(const Value& row); static Value FlapDetectionEnabledAccessor(const Value& row); diff --git a/components/livestatus/statustable.cpp b/components/livestatus/statustable.cpp index 79d8bc7a5..5709f5555 100644 --- a/components/livestatus/statustable.cpp +++ b/components/livestatus/statustable.cpp @@ -79,7 +79,7 @@ void StatusTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "check_service_freshness", Column(&Table::OneAccessor, objectAccessor)); table->AddColumn(prefix + "check_host_freshness", Column(&Table::OneAccessor, objectAccessor)); table->AddColumn(prefix + "enable_flap_detection", Column(&Table::OneAccessor, objectAccessor)); - table->AddColumn(prefix + "process_performance_data", Column(&Table::OneAccessor, objectAccessor)); + table->AddColumn(prefix + "process_performance_data", Column(&StatusTable::ProcessPerformanceDataAccessor, objectAccessor)); table->AddColumn(prefix + "check_external_commands", Column(&Table::OneAccessor, objectAccessor)); table->AddColumn(prefix + "program_start", Column(&StatusTable::ProgramStartAccessor, objectAccessor)); table->AddColumn(prefix + "last_command_check", Column(&Table::ZeroAccessor, objectAccessor)); @@ -148,6 +148,11 @@ Value StatusTable::NagiosPidAccessor(const Value& row) return Utility::GetPid(); } +Value StatusTable::ProcessPerformanceDataAccessor(const Value&) +{ + return (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0); +} + Value StatusTable::ProgramStartAccessor(const Value& row) { return static_cast(Application::GetStartTime()); diff --git a/components/livestatus/statustable.h b/components/livestatus/statustable.h index 2e870bcac..4098899b9 100644 --- a/components/livestatus/statustable.h +++ b/components/livestatus/statustable.h @@ -52,6 +52,7 @@ protected: static Value ExternalCommandsAccessor(const Value& row); static Value ExternalCommandsRateAccessor(const Value& row); static Value NagiosPidAccessor(const Value& row); + static Value ProcessPerformanceDataAccessor(const Value& row); static Value ProgramStartAccessor(const Value& row); static Value NumHostsAccessor(const Value& row); static Value NumServicesAccessor(const Value& row); diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 92c0c6ac0..1a16fe7d2 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -100,7 +100,7 @@ void DbConnection::ProgramStatusHandler(void) query2.Fields->Set("event_handlers_enabled", 1); query2.Fields->Set("flap_detection_enabled", 1); query2.Fields->Set("failure_prediction_enabled", 1); - query2.Fields->Set("process_performance_data", 1); + query2.Fields->Set("process_performance_data", (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0)); DbObject::OnQuery(query2); DbQuery query3; -- 2.40.0