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

index e86f201263792057e26f9eecaff503eb4f0a390c..ac87a15295fb9ca4c40fc2101a7fe6c4c5055237 100644 (file)
@@ -210,17 +210,6 @@ int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkab
        return 0;
 }
 
-int CompatUtility::GetCheckableInCheckPeriod(const Checkable::Ptr& checkable)
-{
-       TimePeriod::Ptr timeperiod = checkable->GetCheckPeriod();
-
-       /* none set means always checked */
-       if (!timeperiod)
-               return 1;
-
-       return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
-}
-
 int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable)
 {
        for (const Notification::Ptr& notification : checkable->GetNotifications()) {
index 4f1c59c600b4791019a4f8e15703abf972e3f028..ee2bf3f2eeccef00521fa3b275a55710e04baff2 100644 (file)
@@ -56,7 +56,6 @@ public:
        static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
 
        static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
-       static int GetCheckableInCheckPeriod(const Checkable::Ptr& checkable);
        static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
 
        /* notification */
index 17ea108b42217e3415e2db92c8a1c01fe5d70902..2bc48ea0cb99a006035c3dafee2ba6e5e728a3bd 100644 (file)
@@ -884,7 +884,13 @@ Value HostsTable::InCheckPeriodAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       return CompatUtility::GetCheckableInCheckPeriod(host);
+       TimePeriod::Ptr timeperiod = host->GetCheckPeriod();
+
+       /* none set means always checked */
+       if (!timeperiod)
+               return 1;
+
+       return Convert::ToLong(timeperiod->IsInside(Utility::GetTime()));
 }
 
 Value HostsTable::ContactsAccessor(const Value& row)
index 1a7d3847daa70ce1da17051e7f4fd62e51cc08ca..00b11616ca5abb4e3d628b7214e24df482d8d8f5 100644 (file)
@@ -895,7 +895,13 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCheckableInCheckPeriod(service);
+       TimePeriod::Ptr timeperiod = service->GetCheckPeriod();
+
+       /* none set means always checked */
+       if (!timeperiod)
+               return 1;
+
+       return Convert::ToLong(timeperiod->IsInside(Utility::GetTime()));
 }
 
 Value ServicesTable::InNotificationPeriodAccessor(const Value& row)