From d373b0390794e43d759fadb253c3a7a10d3634f2 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 20 Dec 2017 16:46:50 +0100 Subject: [PATCH] Drop CompatUtility::GetCheckable*Interval() and hardcode their minute representation in compat features --- lib/compat/statusdatawriter.cpp | 12 ++++++------ lib/db_ido/hostdbobject.cpp | 8 ++++---- lib/db_ido/servicedbobject.cpp | 8 ++++---- lib/icinga/compatutility.cpp | 12 ------------ lib/icinga/compatutility.hpp | 2 -- lib/livestatus/hoststable.cpp | 4 ++-- lib/livestatus/servicestable.cpp | 4 ++-- 7 files changed, 18 insertions(+), 32 deletions(-) diff --git a/lib/compat/statusdatawriter.cpp b/lib/compat/statusdatawriter.cpp index 24be99a68..768059d5b 100644 --- a/lib/compat/statusdatawriter.cpp +++ b/lib/compat/statusdatawriter.cpp @@ -264,8 +264,8 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host) ObjectLock olock(host); - fp << "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(host) << "\n" - "\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(host) << "\n" + fp << "\t" "check_interval" "\t" << (host->GetCheckInterval() / 60.0) << "\n" + "\t" "retry_interval" "\t" << (host->GetRetryInterval() / 60.0) << "\n" "\t" "max_check_attempts" "\t" << host->GetMaxCheckAttempts() << "\n" "\t" "active_checks_enabled" "\t" << Convert::ToLong(host->GetEnableActiveChecks()) << "\n" "\t" "passive_checks_enabled" "\t" << Convert::ToLong(host->GetEnablePassiveChecks()) << "\n" @@ -338,8 +338,8 @@ void StatusDataWriter::DumpCheckableStatusAttrs(std::ostream& fp, const Checkabl fp << "\t" << "check_command=" << CompatUtility::GetCommandName(checkcommand) << "!" << CompatUtility::GetCheckableCommandArgs(checkable) << "\n" "\t" "event_handler=" << CompatUtility::GetCommandName(eventcommand) << "\n" - "\t" "check_interval=" << CompatUtility::GetCheckableCheckInterval(checkable) << "\n" - "\t" "retry_interval=" << CompatUtility::GetCheckableRetryInterval(checkable) << "\n" + "\t" "check_interval=" << (checkable->GetCheckInterval() / 60.0) << "\n" + "\t" "retry_interval=" << (checkable->GetRetryInterval() / 60.0) << "\n" "\t" "has_been_checked=" << Convert::ToLong(checkable->HasBeenChecked()) << "\n" "\t" "should_be_scheduled=" << checkable->GetEnableActiveChecks() << "\n" "\t" "event_handler_enabled=" << Convert::ToLong(checkable->GetEnableEventHandler()) << "\n"; @@ -432,8 +432,8 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s "\t" "host_name" "\t" << host->GetName() << "\n" "\t" "service_description" "\t" << service->GetShortName() << "\n" "\t" "display_name" "\t" << service->GetDisplayName() << "\n" - "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(service) << "\n" - "\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(service) << "\n" + "\t" "check_interval" "\t" << (service->GetCheckInterval() / 60.0) << "\n" + "\t" "retry_interval" "\t" << (service->GetRetryInterval() / 60.0) << "\n" "\t" "max_check_attempts" "\t" << service->GetMaxCheckAttempts() << "\n" "\t" "active_checks_enabled" "\t" << Convert::ToLong(service->GetEnableActiveChecks()) << "\n" "\t" "passive_checks_enabled" "\t" << Convert::ToLong(service->GetEnablePassiveChecks()) << "\n" diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index c7eb4c89e..393bbbb04 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -68,8 +68,8 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const fields->Set("notification_timeperiod_object_id", Empty); fields->Set("check_timeperiod_object_id", host->GetCheckPeriod()); fields->Set("failure_prediction_options", Empty); - fields->Set("check_interval", CompatUtility::GetCheckableCheckInterval(host)); - fields->Set("retry_interval", CompatUtility::GetCheckableRetryInterval(host)); + fields->Set("check_interval", (host->GetCheckInterval() / 60.0)); + fields->Set("retry_interval", (host->GetRetryInterval() / 60.0)); fields->Set("max_check_attempts", host->GetMaxCheckAttempts()); fields->Set("first_notification_delay", Empty); @@ -173,8 +173,8 @@ Dictionary::Ptr HostDbObject::GetStatusFields() const fields->Set("failure_prediction_enabled", Empty); fields->Set("process_performance_data", host->GetEnablePerfdata()); fields->Set("obsess_over_host", Empty); - fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(host)); - fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(host)); + fields->Set("normal_check_interval", (host->GetCheckInterval() / 60.0)); + fields->Set("retry_check_interval", (host->GetRetryInterval() / 60.0)); fields->Set("check_timeperiod_object_id", host->GetCheckPeriod()); fields->Set("is_reachable", host->IsReachable()); diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index b39e600da..b50ebe13d 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -63,8 +63,8 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const fields->Set("notification_timeperiod_object_id", Empty); fields->Set("check_timeperiod_object_id", service->GetCheckPeriod()); fields->Set("failure_prediction_options", Empty); - fields->Set("check_interval", CompatUtility::GetCheckableCheckInterval(service)); - fields->Set("retry_interval", CompatUtility::GetCheckableRetryInterval(service)); + fields->Set("check_interval", (service->GetCheckInterval() / 60.0)); + fields->Set("retry_interval", (service->GetRetryInterval() / 60.0)); fields->Set("max_check_attempts", service->GetMaxCheckAttempts()); fields->Set("first_notification_delay", Empty); fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(service)); @@ -159,8 +159,8 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields() const fields->Set("scheduled_downtime_depth", service->GetDowntimeDepth()); fields->Set("process_performance_data", service->GetEnablePerfdata()); - fields->Set("normal_check_interval", CompatUtility::GetCheckableCheckInterval(service)); - fields->Set("retry_check_interval", CompatUtility::GetCheckableRetryInterval(service)); + fields->Set("normal_check_interval", (service->GetCheckInterval() / 60.0)); + fields->Set("retry_check_interval", (service->GetRetryInterval() / 60.0)); fields->Set("check_timeperiod_object_id", service->GetCheckPeriod()); fields->Set("is_reachable", service->IsReachable()); diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 4583284bb..89a0cb95b 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -188,18 +188,6 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable) return Empty; } -/* Used in DB IDO, StatusDataWriter and Livestatus. */ -double CompatUtility::GetCheckableCheckInterval(const Checkable::Ptr& checkable) -{ - return checkable->GetCheckInterval() / 60.0; -} - -/* Used in DB IDO, StatusDataWriter and Livestatus. */ -double CompatUtility::GetCheckableRetryInterval(const Checkable::Ptr& checkable) -{ - return checkable->GetRetryInterval() / 60.0; -} - /* Used in Livestatus. */ int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable) { diff --git a/lib/icinga/compatutility.hpp b/lib/icinga/compatutility.hpp index 6ecf6b81a..20ea8c601 100644 --- a/lib/icinga/compatutility.hpp +++ b/lib/icinga/compatutility.hpp @@ -47,8 +47,6 @@ public: /* service */ static String GetCheckableCommandArgs(const Checkable::Ptr& checkable); - static double GetCheckableCheckInterval(const Checkable::Ptr& checkable); - static double GetCheckableRetryInterval(const Checkable::Ptr& checkable); static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable); static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable); diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index b5959b9bc..08e6104e1 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -789,7 +789,7 @@ Value HostsTable::CheckIntervalAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableCheckInterval(host); + return host->GetCheckInterval() / 60.0; } Value HostsTable::RetryIntervalAccessor(const Value& row) @@ -799,7 +799,7 @@ Value HostsTable::RetryIntervalAccessor(const Value& row) if (!host) return Empty; - return CompatUtility::GetCheckableRetryInterval(host); + return host->GetRetryInterval() / 60.0; } Value HostsTable::NotificationIntervalAccessor(const Value& row) diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index 1e9283bd8..c3a941c5e 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -810,7 +810,7 @@ Value ServicesTable::CheckIntervalAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableCheckInterval(service); + return service->GetCheckInterval() / 60.0; } Value ServicesTable::RetryIntervalAccessor(const Value& row) @@ -820,7 +820,7 @@ Value ServicesTable::RetryIntervalAccessor(const Value& row) if (!service) return Empty; - return CompatUtility::GetCheckableRetryInterval(service); + return service->GetRetryInterval() / 60.0; } Value ServicesTable::NotificationIntervalAccessor(const Value& row) -- 2.40.0