Move CompatUtility::GetCheckableInCheckPeriod() into Livestatus feature

This commit is contained in:
Michael Friedrich 2017-12-06 17:34:09 +01:00
parent 15e3524e42
commit ce8bfdfa5a
4 changed files with 14 additions and 14 deletions

View File

@ -210,17 +210,6 @@ int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkab
return 0; 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) int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable)
{ {
for (const Notification::Ptr& notification : checkable->GetNotifications()) { for (const Notification::Ptr& notification : checkable->GetNotifications()) {

View File

@ -56,7 +56,6 @@ public:
static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable); static String GetCheckableCheckPeriod(const Checkable::Ptr& checkable);
static int GetCheckableNoMoreNotifications(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); static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
/* notification */ /* notification */

View File

@ -884,7 +884,13 @@ Value HostsTable::InCheckPeriodAccessor(const Value& row)
if (!host) if (!host)
return Empty; 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) Value HostsTable::ContactsAccessor(const Value& row)

View File

@ -895,7 +895,13 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row)
if (!service) if (!service)
return Empty; 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) Value ServicesTable::InNotificationPeriodAccessor(const Value& row)