mirror of https://github.com/Icinga/icinga2.git
Move the IDO specific compat notification filter logic into the feature
This commit is contained in:
parent
d373b03907
commit
48516560bc
|
@ -75,12 +75,17 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const
|
|||
fields->Set("first_notification_delay", Empty);
|
||||
|
||||
fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(host));
|
||||
fields->Set("notify_on_down", CompatUtility::GetHostNotifyOnDown(host));
|
||||
fields->Set("notify_on_unreachable", CompatUtility::GetHostNotifyOnDown(host));
|
||||
|
||||
fields->Set("notify_on_recovery", CompatUtility::GetCheckableNotifyOnRecovery(host));
|
||||
fields->Set("notify_on_flapping", CompatUtility::GetCheckableNotifyOnFlapping(host));
|
||||
fields->Set("notify_on_downtime", CompatUtility::GetCheckableNotifyOnDowntime(host));
|
||||
unsigned long notificationStateFilter = CompatUtility::GetCheckableNotificationTypeFilter(host);
|
||||
unsigned long notificationTypeFilter = CompatUtility::GetCheckableNotificationTypeFilter(host);
|
||||
|
||||
fields->Set("notify_on_down", (notificationStateFilter & ServiceWarning) || (notificationStateFilter && ServiceCritical));
|
||||
fields->Set("notify_on_unreachable", 1); /* We don't have this filter and state, and as such we don't filter such notifications. */
|
||||
fields->Set("notify_on_recovery", notificationTypeFilter & NotificationRecovery);
|
||||
fields->Set("notify_on_flapping", (notificationTypeFilter & NotificationFlappingStart) ||
|
||||
(notificationTypeFilter & NotificationFlappingEnd));
|
||||
fields->Set("notify_on_downtime", (notificationTypeFilter & NotificationDowntimeStart) ||
|
||||
(notificationTypeFilter & NotificationDowntimeEnd) || (notificationTypeFilter & NotificationDowntimeRemoved));
|
||||
|
||||
fields->Set("stalk_on_up", Empty);
|
||||
fields->Set("stalk_on_down", Empty);
|
||||
|
|
|
@ -68,12 +68,19 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields() const
|
|||
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||
fields->Set("first_notification_delay", Empty);
|
||||
fields->Set("notification_interval", CompatUtility::GetCheckableNotificationNotificationInterval(service));
|
||||
fields->Set("notify_on_warning", CompatUtility::GetCheckableNotifyOnWarning(service));
|
||||
fields->Set("notify_on_unknown", CompatUtility::GetCheckableNotifyOnUnknown(service));
|
||||
fields->Set("notify_on_critical", CompatUtility::GetCheckableNotifyOnCritical(service));
|
||||
fields->Set("notify_on_recovery", CompatUtility::GetCheckableNotifyOnRecovery(service));
|
||||
fields->Set("notify_on_flapping", CompatUtility::GetCheckableNotifyOnFlapping(service));
|
||||
fields->Set("notify_on_downtime", CompatUtility::GetCheckableNotifyOnDowntime(service));
|
||||
|
||||
unsigned long notificationStateFilter = CompatUtility::GetCheckableNotificationTypeFilter(service);
|
||||
unsigned long notificationTypeFilter = CompatUtility::GetCheckableNotificationTypeFilter(service);
|
||||
|
||||
fields->Set("notify_on_warning", notificationStateFilter & ServiceWarning);
|
||||
fields->Set("notify_on_unknown", notificationStateFilter & ServiceUnknown);
|
||||
fields->Set("notify_on_critical", notificationStateFilter & ServiceCritical);
|
||||
fields->Set("notify_on_recovery", notificationTypeFilter & NotificationRecovery);
|
||||
fields->Set("notify_on_flapping", (notificationTypeFilter & NotificationFlappingStart) ||
|
||||
(notificationTypeFilter & NotificationFlappingEnd));
|
||||
fields->Set("notify_on_downtime", (notificationTypeFilter & NotificationDowntimeStart) ||
|
||||
(notificationTypeFilter & NotificationDowntimeEnd) || (notificationTypeFilter & NotificationDowntimeRemoved));
|
||||
|
||||
fields->Set("stalk_on_ok", 0);
|
||||
fields->Set("stalk_on_warning", 0);
|
||||
fields->Set("stalk_on_unknown", 0);
|
||||
|
|
|
@ -99,29 +99,6 @@ String CompatUtility::GetHostStateString(const Host::Ptr& host)
|
|||
return Host::StateToString(host->GetState());
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetHostNotifyOnDown(const Host::Ptr& host)
|
||||
{
|
||||
unsigned long notification_state_filter = GetCheckableNotificationStateFilter(host);
|
||||
|
||||
if ((notification_state_filter & ServiceCritical) ||
|
||||
(notification_state_filter & ServiceWarning))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetHostNotifyOnUnreachable(const Host::Ptr& host)
|
||||
{
|
||||
unsigned long notification_state_filter = GetCheckableNotificationStateFilter(host);
|
||||
|
||||
if (notification_state_filter & ServiceUnknown)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
|
||||
{
|
||||
|
@ -188,15 +165,6 @@ String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
|
|||
return Empty;
|
||||
}
|
||||
|
||||
/* Used in Livestatus. */
|
||||
int CompatUtility::GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (CompatUtility::GetCheckableNotificationNotificationInterval(checkable) == 0 && !checkable->GetVolatile())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in Livestatus. */
|
||||
int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable)
|
||||
{
|
||||
|
@ -290,67 +258,6 @@ int CompatUtility::GetCheckableNotificationStateFilter(const Checkable::Ptr& che
|
|||
return notification_state_filter;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetCheckableNotifyOnWarning(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationStateFilter(checkable) & ServiceWarning)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetCheckableNotifyOnCritical(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationStateFilter(checkable) & ServiceCritical)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetCheckableNotifyOnUnknown(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationStateFilter(checkable) & ServiceUnknown)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetCheckableNotifyOnRecovery(const Checkable::Ptr& checkable)
|
||||
{
|
||||
if (GetCheckableNotificationTypeFilter(checkable) & NotificationRecovery)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetCheckableNotifyOnFlapping(const Checkable::Ptr& checkable)
|
||||
{
|
||||
unsigned long notification_type_filter = GetCheckableNotificationTypeFilter(checkable);
|
||||
|
||||
if ((notification_type_filter & NotificationFlappingStart) ||
|
||||
(notification_type_filter & NotificationFlappingEnd))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO. */
|
||||
int CompatUtility::GetCheckableNotifyOnDowntime(const Checkable::Ptr& checkable)
|
||||
{
|
||||
unsigned long notification_type_filter = GetCheckableNotificationTypeFilter(checkable);
|
||||
|
||||
if ((notification_type_filter & NotificationDowntimeStart) ||
|
||||
(notification_type_filter & NotificationDowntimeEnd) ||
|
||||
(notification_type_filter & NotificationDowntimeRemoved))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
std::set<User::Ptr> CompatUtility::GetCheckableNotificationUsers(const Checkable::Ptr& checkable)
|
||||
{
|
||||
|
|
|
@ -42,13 +42,10 @@ public:
|
|||
/* host */
|
||||
static int GetHostCurrentState(const Host::Ptr& host);
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
static int GetHostNotifyOnDown(const Host::Ptr& host);
|
||||
static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
|
||||
|
||||
/* service */
|
||||
static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
|
||||
|
||||
static int GetCheckableNoMoreNotifications(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableInNotificationPeriod(const Checkable::Ptr& checkable);
|
||||
|
||||
/* notification */
|
||||
|
@ -59,12 +56,6 @@ public:
|
|||
static double GetCheckableNotificationNotificationInterval(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotificationTypeFilter(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotificationStateFilter(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnWarning(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnCritical(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnUnknown(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnRecovery(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnFlapping(const Checkable::Ptr& checkable);
|
||||
static int GetCheckableNotifyOnDowntime(const Checkable::Ptr& checkable);
|
||||
|
||||
static std::set<User::Ptr> GetCheckableNotificationUsers(const Checkable::Ptr& checkable);
|
||||
static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
|
||||
|
|
|
@ -699,7 +699,7 @@ Value HostsTable::NoMoreNotificationsAccessor(const Value& row)
|
|||
if (!host)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableNoMoreNotifications(host);
|
||||
return (CompatUtility::GetCheckableNotificationNotificationInterval(host) == 0 && !host->GetVolatile()) ? 1 : 0;
|
||||
}
|
||||
|
||||
Value HostsTable::LastCheckAccessor(const Value& row)
|
||||
|
|
|
@ -587,7 +587,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
|||
if (!service)
|
||||
return Empty;
|
||||
|
||||
return CompatUtility::GetCheckableNoMoreNotifications(service);
|
||||
return (CompatUtility::GetCheckableNotificationNotificationInterval(service) == 0 && !service->GetVolatile()) ? 1 : 0;
|
||||
}
|
||||
|
||||
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
||||
|
|
Loading…
Reference in New Issue