]> granicus.if.org Git - icinga2/commitdiff
Drop CompatUtility::GetCheckableCheckPeriod()
authorMichael Friedrich <michael.friedrich@icinga.com>
Wed, 6 Dec 2017 16:49:53 +0000 (17:49 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 15 Jan 2018 12:39:34 +0000 (13:39 +0100)
lib/compat/statusdatawriter.cpp
lib/icinga/compatutility.cpp
lib/icinga/compatutility.hpp
lib/livestatus/hoststable.cpp
lib/livestatus/servicestable.cpp

index 142fdd91e64ab005c1e9dda1c471af2f61c5efc3..24be99a682408b8624d9bc13ee9cdb4c0feb4400 100644 (file)
@@ -282,7 +282,9 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
        if (eventcommand && host->GetEnableEventHandler())
                fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n";
 
-       fp << "\t" "check_period" "\t" << CompatUtility::GetCheckableCheckPeriod(host) << "\n";
+       TimePeriod::Ptr checkPeriod = host->GetCheckPeriod();
+       if (checkPeriod)
+               fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n";
 
        fp << "\t" "contacts" "\t";
        DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(host));
@@ -336,13 +338,16 @@ 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_period=" << CompatUtility::GetCheckableCheckPeriod(checkable) << "\n"
                "\t" "check_interval=" << CompatUtility::GetCheckableCheckInterval(checkable) << "\n"
                "\t" "retry_interval=" << CompatUtility::GetCheckableRetryInterval(checkable) << "\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";
 
+       TimePeriod::Ptr checkPeriod = checkable->GetCheckPeriod();
+       if (checkPeriod)
+               fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n";
+
        if (cr) {
                fp << "\t" << "check_execution_time=" << Convert::ToString(cr->CalculateExecutionTime()) << "\n"
                        "\t" "check_latency=" << Convert::ToString(cr->CalculateLatency()) << "\n";
@@ -427,7 +432,6 @@ 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_period" "\t" << CompatUtility::GetCheckableCheckPeriod(service) << "\n"
                        "\t" "check_interval" "\t" << CompatUtility::GetCheckableCheckInterval(service) << "\n"
                        "\t" "retry_interval" "\t" << CompatUtility::GetCheckableRetryInterval(service) << "\n"
                        "\t" "max_check_attempts" "\t" << service->GetMaxCheckAttempts() << "\n"
@@ -449,6 +453,10 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
                if (eventcommand && service->GetEnableEventHandler())
                        fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n";
 
+               TimePeriod::Ptr checkPeriod = service->GetCheckPeriod();
+               if (checkPeriod)
+                       fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n";
+
                fp << "\t" "contacts" "\t";
                DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(service));
                fp << "\n";
index ac87a15295fb9ca4c40fc2101a7fe6c4c5055237..2b030b3fab5f7afbbcd4ea52af235f043aae9677 100644 (file)
@@ -193,15 +193,6 @@ double CompatUtility::GetCheckableRetryInterval(const Checkable::Ptr& checkable)
        return checkable->GetRetryInterval() / 60.0;
 }
 
-String CompatUtility::GetCheckableCheckPeriod(const Checkable::Ptr& checkable)
-{
-       TimePeriod::Ptr check_period = checkable->GetCheckPeriod();
-       if (check_period)
-               return check_period->GetName();
-       else
-               return "24x7";
-}
-
 int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable)
 {
        if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile())
index ee2bf3f2eeccef00521fa3b275a55710e04baff2..8dac5d1e904e474916606bd10b9f42beff7b5e2c 100644 (file)
@@ -53,7 +53,6 @@ public:
        static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
        static double GetCheckableCheckInterval(const Checkable::Ptr& checkable);
        static double GetCheckableRetryInterval(const Checkable::Ptr& checkable);
-       static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
 
        static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
        static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
index 2bc48ea0cb99a006035c3dafee2ba6e5e728a3bd..b5959b9bc05a3f09bb5d179714624df0828ac941 100644 (file)
@@ -304,7 +304,12 @@ Value HostsTable::CheckPeriodAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       return CompatUtility::GetCheckableCheckPeriod(host);
+       TimePeriod::Ptr checkPeriod = host->GetCheckPeriod();
+
+       if (!checkPeriod)
+               return Empty;
+
+       return checkPeriod->GetName();
 }
 
 Value HostsTable::NotesAccessor(const Value& row)
index 00b11616ca5abb4e3d628b7214e24df482d8d8f5..1e9283bd81b53f3152120bab792907c14533d6a2 100644 (file)
@@ -356,7 +356,12 @@ Value ServicesTable::CheckPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCheckableCheckPeriod(service);
+       TimePeriod::Ptr checkPeriod = service->GetCheckPeriod();
+
+       if (!checkPeriod)
+               return Empty;
+
+       return checkPeriod->GetName();
 }
 
 Value ServicesTable::NotesAccessor(const Value& row)