Implement override_enable_notifications.

Refs #4746
This commit is contained in:
Gunnar Beutner 2013-11-26 11:18:05 +01:00
parent 1ced583171
commit 04061adc01
4 changed files with 16 additions and 5 deletions

View File

@ -76,6 +76,7 @@ type Service {
%attribute number "check_interval",
%attribute number "retry_interval",
%attribute number "enable_notifications",
%attribute number "enable_active_checks",
%attribute number "enable_passive_checks",
%attribute number "enable_event_handler",

View File

@ -163,12 +163,15 @@ void Service::UpdateSlaveNotifications(void)
bool Service::GetEnableNotifications(void) const
{
return GetEnableNotificationsRaw();
if (!GetOverrideEnableNotifications().IsEmpty())
return GetOverrideEnableNotifications();
else
return GetEnableNotifications();
}
void Service::SetEnableNotifications(bool enabled, const String& authority)
{
SetEnableNotificationsRaw(enabled);
SetOverrideEnableActiveChecks(enabled);
OnEnableNotificationsChanged(GetSelf(), enabled, authority);
}

View File

@ -264,6 +264,9 @@ int Service::GetModifiedAttributes(void) const
{
int attrs = 0;
if (!GetOverrideEnableNotifications().IsEmpty())
attrs |= ModAttrNotificationsEnabled;
if (!GetOverrideEnableActiveChecks().IsEmpty())
attrs |= ModAttrActiveChecksEnabled;
@ -286,6 +289,9 @@ int Service::GetModifiedAttributes(void) const
void Service::SetModifiedAttributes(int flags)
{
if ((flags & ModAttrNotificationsEnabled) == 0)
SetOverrideEnableNotifications(Empty);
if ((flags & ModAttrActiveChecksEnabled) == 0)
SetOverrideEnableActiveChecks(Empty);

View File

@ -68,6 +68,9 @@ class Service : DynamicObject
[config] bool enable_event_handler (EnableEventHandlerRaw) {
default {{{ return true; }}}
};
[config] bool enable_notifications (EnableNotificationsRaw) {
default {{{ return true; }}}
};
[state] double next_check (NextCheckRaw);
[state] int check_attempt {
@ -115,9 +118,6 @@ class Service : DynamicObject
[state] Dictionary::Ptr downtimes {
default {{{ return make_shared<Dictionary>(); }}}
};
[state] bool enable_notifications (EnableNotificationsRaw) {
default {{{ return true; }}}
};
[state] bool force_next_notification (ForceNextNotificationRaw);
[state] int flapping_positive;
[state] int flapping_negative;
@ -128,6 +128,7 @@ class Service : DynamicObject
[state] bool enable_perfdata {
default {{{ return true; }}}
};
[state] Value override_enable_notifications;
[state] Value override_enable_active_checks;
[state] Value override_enable_passive_checks;
[state] Value override_check_interval;