From b4af0971af62b69aa6640ca0dd477d5a8b70d7f7 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 5 Dec 2017 18:53:22 +0100 Subject: [PATCH] Drop dead code in Livestatus feature --- lib/compat/statusdatawriter.cpp | 6 +++--- lib/db_ido/dbevents.cpp | 4 ++-- lib/db_ido/hostdbobject.cpp | 6 +++--- lib/db_ido/servicedbobject.cpp | 6 +++--- lib/icinga/compatutility.cpp | 15 --------------- lib/icinga/compatutility.hpp | 3 --- lib/livestatus/hoststable.cpp | 10 ++-------- lib/livestatus/hoststable.hpp | 1 - lib/livestatus/servicestable.cpp | 10 ++-------- lib/livestatus/servicestable.hpp | 1 - 10 files changed, 15 insertions(+), 47 deletions(-) diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp index 6282cb9b1..2561e39c8 100644 --- a/lib/compat/statusdatawriter.cpp +++ b/lib/compat/statusdatawriter.cpp @@ -385,8 +385,8 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl "\t" "active_checks_enabled=" << Convert::ToLong(checkable->GetEnableActiveChecks()) << "\n" "\t" "passive_checks_enabled=" << Convert::ToLong(checkable->GetEnablePassiveChecks()) << "\n" "\t" "flap_detection_enabled=" << Convert::ToLong(checkable->GetEnableFlapping()) << "\n" - "\t" "is_flapping=" << CompatUtility::GetCheckableIsFlapping(checkable) << "\n" - "\t" "percent_state_change=" << CompatUtility::GetCheckablePercentStateChange(checkable) << "\n" + "\t" "is_flapping=" << Convert::ToLong(checkable->IsFlapping()) << "\n" + "\t" "percent_state_change=" << checkable->GetFlappingCurrent() << "\n" "\t" "problem_has_been_acknowledged=" << (checkable->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n" "\t" "acknowledgement_type=" << checkable->GetAcknowledgement() << "\n" "\t" "acknowledgement_end_time=" << checkable->GetAcknowledgementExpiry() << "\n" @@ -394,7 +394,7 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl "\t" "last_notification=" << CompatUtility::GetCheckableNotificationLastNotification(checkable) << "\n" "\t" "next_notification=" << CompatUtility::GetCheckableNotificationNextNotification(checkable) << "\n" "\t" "current_notification_number=" << CompatUtility::GetCheckableNotificationNotificationNumber(checkable) << "\n" - "\t" "is_reachable=" << CompatUtility::GetCheckableIsReachable(checkable) << "\n"; + "\t" "is_reachable=" << Convert::ToLong(checkable->IsReachable()) << "\n"; } void StatusDataWriter::DumpServiceStatus(std::ostream& fp, const Service::Ptr& service) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 6f4e567dc..24ffd0ce1 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -137,8 +137,8 @@ void DbEvents::FlappingChangedHandler(const Checkable::Ptr& checkable) query1.Object = DbObject::GetOrCreateByObject(checkable); Dictionary::Ptr fields1 = new Dictionary(); - fields1->Set("is_flapping", CompatUtility::GetCheckableIsFlapping(checkable)); - fields1->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(checkable)); + fields1->Set("is_flapping", checkable->IsFlapping()); + fields1->Set("percent_state_change", checkable->GetFlappingCurrent()); query1.Fields = fields1; diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 54d3da6d0..8aec40799 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -160,8 +160,8 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const fields->Set("active_checks_enabled", host->GetEnableActiveChecks()); fields->Set("event_handler_enabled", host->GetEnableEventHandler()); fields->Set("flap_detection_enabled", host->GetEnableFlapping()); - fields->Set("is_flapping", CompatUtility::GetCheckableIsFlapping(host)); - fields->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(host)); + fields->Set("is_flapping", host->IsFlapping()); + fields->Set("percent_state_change", host->GetFlappingCurrent()); if (cr) { fields->Set("latency", Convert::ToString(cr->CalculateLatency())); @@ -177,7 +177,7 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(host)); fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(host)); fields->Set("check_timeperiod_object_id", host->GetCheckPeriod()); - fields->Set("is_reachable", CompatUtility::GetCheckableIsReachable(host)); + fields->Set("is_reachable", host->IsReachable()); fields->Set("original_attributes", JsonEncode(host->GetOriginalAttributes())); diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index fc2f4d041..28886fc3f 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -148,8 +148,8 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const fields->Set("active_checks_enabled", service->GetEnableActiveChecks()); fields->Set("event_handler_enabled", service->GetEnableEventHandler()); fields->Set("flap_detection_enabled", service->GetEnableFlapping()); - fields->Set("is_flapping", CompatUtility::GetCheckableIsFlapping(service)); - fields->Set("percent_state_change", CompatUtility::GetCheckablePercentStateChange(service)); + fields->Set("is_flapping", service->IsFlapping()); + fields->Set("percent_state_change", service->GetFlappingCurrent()); if (cr) { fields->Set("latency", Convert::ToString(cr->CalculateLatency())); @@ -163,7 +163,7 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(service)); fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(service)); fields->Set("check_timeperiod_object_id", service->GetCheckPeriod()); - fields->Set("is_reachable", CompatUtility::GetCheckableIsReachable(service)); + fields->Set("is_reachable", service->IsReachable()); fields->Set("original_attributes", JsonEncode(service->GetOriginalAttributes())); diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 7b8d937ee..2f3557a36 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -202,21 +202,6 @@ String CompatUtility::GetCheckableCheckPeriod(const Checkable::Ptr& checkable) return "24x7"; } -int CompatUtility::GetCheckableIsFlapping(const Checkable::Ptr& checkable) -{ - return (checkable->IsFlapping() ? 1 : 0); -} - -int CompatUtility::GetCheckableIsReachable(const Checkable::Ptr& checkable) -{ - return (checkable->IsReachable() ? 1 : 0); -} - -double CompatUtility::GetCheckablePercentStateChange(const Checkable::Ptr& checkable) -{ - return checkable->GetFlappingCurrent(); -} - String CompatUtility::GetCheckableEventHandler(const Checkable::Ptr& checkable) { String event_command_str; diff --git a/lib/icinga/compatutility.hpp b/lib/icinga/compatutility.hpp index 5e6b176ec..4f61279e9 100644 --- a/lib/icinga/compatutility.hpp +++ b/lib/icinga/compatutility.hpp @@ -54,9 +54,6 @@ public: static double GetCheckableCheckInterval(const Checkable::Ptr& checkable); static double GetCheckableRetryInterval(const Checkable::Ptr& checkable); static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable); - static int GetCheckableIsFlapping(const Checkable::Ptr& checkable); - static int GetCheckableIsReachable(const Checkable::Ptr& checkable); - static double GetCheckablePercentStateChange(const Checkable::Ptr& checkable); static String GetCheckableEventHandler(const Checkable::Ptr& checkable); static String GetCheckableCheckCommand(const Checkable::Ptr& checkable); diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index 61e38108f..65994682c 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -108,7 +108,7 @@ void HostsTable::AddColumns(Table *table, const String& prefix, table->AddColumn(prefix + "scheduled_downtime_depth", Column(&HostsTable::ScheduledDowntimeDepthAccessor, objectAccessor)); table->AddColumn(prefix + "is_executing", Column(&Table::ZeroAccessor, objectAccessor)); table->AddColumn(prefix + "active_checks_enabled", Column(&HostsTable::ActiveChecksEnabledAccessor, objectAccessor)); - table->AddColumn(prefix + "check_options", Column(&HostsTable::CheckOptionsAccessor, objectAccessor)); + table->AddColumn(prefix + "check_options", Column(&Table::EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "obsess_over_host", Column(&Table::ZeroAccessor, objectAccessor)); table->AddColumn(prefix + "modified_attributes", Column(&Table::ZeroAccessor, objectAccessor)); table->AddColumn(prefix + "modified_attributes_list", Column(&Table::ZeroAccessor, objectAccessor)); @@ -776,12 +776,6 @@ Value HostsTable::ActiveChecksEnabledAccessor(const Value& row) return Convert::ToLong(host->GetEnableActiveChecks()); } -Value HostsTable::CheckOptionsAccessor(const Value&) -{ - /* TODO - forcexec, freshness, orphan, none */ - return Empty; -} - Value HostsTable::CheckIntervalAccessor(const Value& row) { Host::Ptr host = static_cast(row); @@ -869,7 +863,7 @@ Value HostsTable::PercentStateChangeAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckablePercentStateChange(host); + return host->GetFlappingCurrent(); } Value HostsTable::InNotificationPeriodAccessor(const Value& row) diff --git a/lib/livestatus/hoststable.hpp b/lib/livestatus/hoststable.hpp index c6e34bb3b..9a08bec0c 100644 --- a/lib/livestatus/hoststable.hpp +++ b/lib/livestatus/hoststable.hpp @@ -99,7 +99,6 @@ protected: static Value IsFlappingAccessor(const Value& row); static Value ScheduledDowntimeDepthAccessor(const Value& row); static Value ActiveChecksEnabledAccessor(const Value& row); - static Value CheckOptionsAccessor(const Value& row); static Value CheckIntervalAccessor(const Value& row); static Value RetryIntervalAccessor(const Value& row); static Value NotificationIntervalAccessor(const Value& row); diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index e3aa936f5..c9cec7c39 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -103,7 +103,7 @@ void ServicesTable::AddColumns(Table *table, const String& prefix, 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 + "check_options", Column(&Table::EmptyStringAccessor, objectAccessor)); table->AddColumn(prefix + "flap_detection_enabled", Column(&ServicesTable::FlapDetectionEnabledAccessor, objectAccessor)); table->AddColumn(prefix + "check_freshness", Column(&ServicesTable::CheckFreshnessAccessor, objectAccessor)); table->AddColumn(prefix + "obsess_over_service", Column(&Table::ZeroAccessor, objectAccessor)); @@ -774,12 +774,6 @@ Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row) return Convert::ToLong(service->GetEnableActiveChecks()); } -Value ServicesTable::CheckOptionsAccessor(const Value& row) -{ - /* TODO - forcexec, freshness, orphan, none */ - return Empty; -} - Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row) { Service::Ptr service = static_cast(row); @@ -897,7 +891,7 @@ Value ServicesTable::PercentStateChangeAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckablePercentStateChange(service); + return service->GetFlappingCurrent(); } Value ServicesTable::InCheckPeriodAccessor(const Value& row) diff --git a/lib/livestatus/servicestable.hpp b/lib/livestatus/servicestable.hpp index 665557236..afa9c84cd 100644 --- a/lib/livestatus/servicestable.hpp +++ b/lib/livestatus/servicestable.hpp @@ -98,7 +98,6 @@ protected: 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); static Value CheckFreshnessAccessor(const Value& row); static Value StalenessAccessor(const Value& row);