Move CompatUtility::GetCheckableInNotificationPeriod() logic into Livestatus feature

This commit is contained in:
Michael Friedrich 2017-12-21 09:36:51 +01:00
parent 7a012c062a
commit 9de233630a
4 changed files with 16 additions and 17 deletions

View 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)
{

View 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);

View 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)

View 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)