]> granicus.if.org Git - icinga2/commitdiff
Remove more redundant wrappers from CompatUtility class
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 5 Dec 2017 18:51:34 +0000 (19:51 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 15 Jan 2018 12:39:34 +0000 (13:39 +0100)
lib/compat/statusdatawriter.cpp
lib/db_ido/hostdbobject.cpp
lib/db_ido/servicedbobject.cpp
lib/icinga/compatutility.cpp
lib/icinga/compatutility.hpp
lib/livestatus/hoststable.cpp
lib/livestatus/servicestable.cpp

index 2561e39c807e3775915f5f350c6bab4395f69b1f..bbc55991823288473136f760e149490cb0f03e26 100644 (file)
@@ -434,7 +434,7 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
                        "\t" "active_checks_enabled" "\t" << Convert::ToLong(service->GetEnableActiveChecks()) << "\n"
                        "\t" "passive_checks_enabled" "\t" << Convert::ToLong(service->GetEnablePassiveChecks()) << "\n"
                        "\t" "flap_detection_enabled" "\t" << Convert::ToLong(service->GetEnableFlapping()) << "\n"
-                       "\t" "is_volatile" "\t" << CompatUtility::GetCheckableIsVolatile(service) << "\n"
+                       "\t" "is_volatile" "\t" << Convert::ToLong(service->GetVolatile()) << "\n"
                        "\t" "notifications_enabled" "\t" << Convert::ToLong(service->GetEnableNotifications()) << "\n"
                        "\t" "notification_options" "\t" << CompatUtility::GetCheckableNotificationNotificationOptions(service) << "\n"
                        "\t" "notification_interval" "\t" << CompatUtility::GetCheckableNotificationNotificationInterval(service) << "\n"
index 8cb682409a0bb226ebaf0393353ff89450908a82..0ce0209bee63e29d40a956fc449a332efaa0eabf 100644 (file)
@@ -89,8 +89,8 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const
        fields->Set("flap_detection_on_up", Empty);
        fields->Set("flap_detection_on_down", Empty);
        fields->Set("flap_detection_on_unreachable", Empty);
-       fields->Set("low_flap_threshold", CompatUtility::GetCheckableLowFlapThreshold(host));
-       fields->Set("high_flap_threshold", CompatUtility::GetCheckableHighFlapThreshold(host));
+       fields->Set("low_flap_threshold", host->GetFlappingThresholdLow());
+       fields->Set("high_flap_threshold", host->GetFlappingThresholdLow());
 
        fields->Set("process_performance_data", host->GetEnablePerfdata());
 
index 597ad08dee2da2294c93a2a907dac95abf312de4..24a52218906112b34773e98342a8a891af691910 100644 (file)
@@ -77,14 +77,14 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const
        fields->Set("stalk_on_warning", 0);
        fields->Set("stalk_on_unknown", 0);
        fields->Set("stalk_on_critical", 0);
-       fields->Set("is_volatile", CompatUtility::GetCheckableIsVolatile(service));
+       fields->Set("is_volatile", service->GetVolatile());
        fields->Set("flap_detection_enabled", service->GetEnableFlapping());
        fields->Set("flap_detection_on_ok", Empty);
        fields->Set("flap_detection_on_warning", Empty);
        fields->Set("flap_detection_on_unknown", Empty);
        fields->Set("flap_detection_on_critical", Empty);
-       fields->Set("low_flap_threshold", CompatUtility::GetCheckableLowFlapThreshold(service));
-       fields->Set("high_flap_threshold", CompatUtility::GetCheckableHighFlapThreshold(service));
+       fields->Set("low_flap_threshold", service->GetFlappingThresholdLow());
+       fields->Set("high_flap_threshold", service->GetFlappingThresholdLow());
        fields->Set("process_performance_data", service->GetEnablePerfdata());
        fields->Set("freshness_checks_enabled", CompatUtility::GetCheckableFreshnessChecksEnabled(service));
        fields->Set("freshness_threshold", CompatUtility::GetCheckableFreshnessThreshold(service));
index 031754a9e674cb78a0631cde6595213188f8361e..7baf65bbd3f6f6bcc1fdf2360174f4711fbb1c15 100644 (file)
@@ -202,21 +202,6 @@ String CompatUtility::GetCheckableCheckPeriod(const Checkable::Ptr& checkable)
                return "24x7";
 }
 
-int CompatUtility::GetCheckableIsVolatile(const Checkable::Ptr& checkable)
-{
-       return (checkable->GetVolatile() ? 1 : 0);
-}
-
-double CompatUtility::GetCheckableLowFlapThreshold(const Checkable::Ptr& checkable)
-{
-       return checkable->GetFlappingThresholdLow();
-}
-
-double CompatUtility::GetCheckableHighFlapThreshold(const Checkable::Ptr& checkable)
-{
-       return checkable->GetFlappingThresholdHigh();
-}
-
 int CompatUtility::GetCheckableFreshnessChecksEnabled(const Checkable::Ptr& checkable)
 {
        return (checkable->GetCheckInterval() > 0 ? 1 : 0);
@@ -227,19 +212,6 @@ int CompatUtility::GetCheckableFreshnessThreshold(const Checkable::Ptr& checkabl
        return static_cast<int>(checkable->GetCheckInterval());
 }
 
-double CompatUtility::GetCheckableStaleness(const Checkable::Ptr& checkable)
-{
-       if (checkable->HasBeenChecked() && checkable->GetLastCheck() > 0)
-               return (Utility::GetTime() - checkable->GetLastCheck()) / (checkable->GetCheckInterval() * 3600);
-
-       return 0.0;
-}
-
-int CompatUtility::GetCheckableIsAcknowledged(const Checkable::Ptr& checkable)
-{
-       return (checkable->IsAcknowledged() ? 1 : 0);
-}
-
 int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable)
 {
        if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile())
index 0ec8f0eab563a9212bb6992ccb40503a8a06070b..64a6e8cfeb3c2a0aa79bce6ccce84f271aa684aa 100644 (file)
@@ -55,12 +55,8 @@ public:
        static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
        static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
 
-       static int GetCheckableIsVolatile(const Checkable::Ptr& checkable);
-       static double GetCheckableLowFlapThreshold(const Checkable::Ptr& checkable);
-       static double GetCheckableHighFlapThreshold(const Checkable::Ptr& checkable);
        static int GetCheckableFreshnessChecksEnabled(const Checkable::Ptr& checkable);
        static int GetCheckableFreshnessThreshold(const Checkable::Ptr& checkable);
-       static double GetCheckableStaleness(const Checkable::Ptr& checkable);
        static int GetCheckableIsAcknowledged(const Checkable::Ptr& checkable);
        static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
        static int GetCheckableInCheckPeriod(const Checkable::Ptr& checkable);
index 65994682c2359a91298940e0ec81244ee75dd384..6c0157f1b5daad3c6562ff7cb4062848fc205307 100644 (file)
@@ -663,7 +663,7 @@ Value HostsTable::AcknowledgedAccessor(const Value& row)
                return Empty;
 
        ObjectLock olock(host);
-       return CompatUtility::GetCheckableIsAcknowledged(host);
+       return host->IsAcknowledged();
 }
 
 Value HostsTable::StateAccessor(const Value& row)
@@ -813,7 +813,7 @@ Value HostsTable::LowFlapThresholdAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       return CompatUtility::GetCheckableLowFlapThreshold(host);
+       return host->GetFlappingThresholdLow();
 }
 
 Value HostsTable::HighFlapThresholdAccessor(const Value& row)
@@ -823,7 +823,7 @@ Value HostsTable::HighFlapThresholdAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       return CompatUtility::GetCheckableHighFlapThreshold(host);
+       return host->GetFlappingThresholdHigh();
 }
 
 Value HostsTable::LatencyAccessor(const Value& row)
@@ -1394,7 +1394,10 @@ Value HostsTable::StalenessAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       return CompatUtility::GetCheckableStaleness(host);
+       if (host->HasBeenChecked() && host->GetLastCheck() > 0)
+               return (Utility::GetTime() - host->GetLastCheck()) / (host->GetCheckInterval() * 3600);
+
+       return 0.0;
 }
 
 Value HostsTable::GroupsAccessor(const Value& row)
index c9cec7c39d3042e82e3d4473e7c407a135e429f8..4bf363a329b1718c9d66e005efee9e818ffbd704 100644 (file)
@@ -560,7 +560,7 @@ Value ServicesTable::AcknowledgedAccessor(const Value& row)
                return Empty;
 
        ObjectLock olock(service);
-       return CompatUtility::GetCheckableIsAcknowledged(service);
+       return service->IsAcknowledged();
 }
 
 Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
@@ -801,7 +801,10 @@ Value ServicesTable::StalenessAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCheckableStaleness(service);
+       if (service->HasBeenChecked() && service->GetLastCheck() > 0)
+               return (Utility::GetTime() - service->GetLastCheck()) / (service->GetCheckInterval() * 3600);
+
+       return 0.0;
 }
 
 Value ServicesTable::CheckIntervalAccessor(const Value& row)
@@ -841,7 +844,7 @@ Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCheckableLowFlapThreshold(service);
+       return service->GetFlappingThresholdLow();
 }
 
 Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
@@ -851,7 +854,7 @@ Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCheckableHighFlapThreshold(service);
+       return service->GetFlappingThresholdHigh();
 }
 
 Value ServicesTable::LatencyAccessor(const Value& row)