]> granicus.if.org Git - icinga2/commitdiff
Move CompatUtility::GetCheckableInNotificationPeriod() logic into Livestatus feature
authorMichael Friedrich <michael.friedrich@icinga.com>
Thu, 21 Dec 2017 08:36:51 +0000 (09:36 +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 93b39b3b61898cfc1aea31434b9d5d84c5e278dd..3eb0dc573087bba4efcaf85157489dad6c9cec08 100644 (file)
@@ -147,19 +147,6 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
        return Empty;
 }
 
-/* Used in Livestatus. */
-int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable)
-{
-       for (const Notification::Ptr& notification : checkable->GetNotifications()) {
-               TimePeriod::Ptr timeperiod = notification->GetPeriod();
-
-               if (!timeperiod || timeperiod->IsInside(Utility::GetTime()))
-                       return 1;
-       }
-
-       return 0;
-}
-
 /* Used in DB IDO, StatusDataWriter and Livestatus. */
 int CompatUtility::GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable)
 {
index 859f4509f49bc7b2f50da0360123a3c1ff931803..388cdcb057d868788d26ac42dfd062a0cb371a8b 100644 (file)
@@ -42,8 +42,6 @@ public:
        /* service */
        static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
 
-       static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
-
        /* notification */
        static int GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable);
        static int GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable);
index 6e637c258e91344dd19b517c7fdfcf5ee3728ce3..b4ba38fe8d3fbabd4227f0e6207f67e5ca49afe5 100644 (file)
@@ -879,7 +879,14 @@ Value HostsTable::InNotificationPeriodAccessor(const Value& row)
        if (!host)
                return Empty;
 
-       return CompatUtility::GetCheckableInNotificationPeriod(host);
+       for (const Notification::Ptr& notification : host->GetNotifications()) {
+               TimePeriod::Ptr timeperiod = notification->GetPeriod();
+
+               if (!timeperiod || timeperiod->IsInside(Utility::GetTime()))
+                       return 1;
+       }
+
+       return 0;
 }
 
 Value HostsTable::InCheckPeriodAccessor(const Value& row)
index b0c70ce322b6a7cd9096f1eff4d5faa37d2c1d7d..2dcd9db9a57cc27392535a20617759c056752daa 100644 (file)
@@ -916,7 +916,14 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
        if (!service)
                return Empty;
 
-       return CompatUtility::GetCheckableInNotificationPeriod(service);
+       for (const Notification::Ptr& notification : service->GetNotifications()) {
+               TimePeriod::Ptr timeperiod = notification->GetPeriod();
+
+               if (!timeperiod || timeperiod->IsInside(Utility::GetTime()))
+                       return 1;
+       }
+
+       return 0;
 }
 
 Value ServicesTable::ContactsAccessor(const Value& row)