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 "check_interval",
%attribute number "retry_interval", %attribute number "retry_interval",
%attribute number "enable_notifications",
%attribute number "enable_active_checks", %attribute number "enable_active_checks",
%attribute number "enable_passive_checks", %attribute number "enable_passive_checks",
%attribute number "enable_event_handler", %attribute number "enable_event_handler",

View File

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

View File

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

View File

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