From 04061adc01d397aecd1ccec66f63594a9f3601ce Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 26 Nov 2013 11:18:05 +0100 Subject: [PATCH] Implement override_enable_notifications. Refs #4746 --- lib/icinga/icinga-type.conf | 1 + lib/icinga/service-notification.cpp | 7 +++++-- lib/icinga/service.cpp | 6 ++++++ lib/icinga/service.ti | 7 ++++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/icinga/icinga-type.conf b/lib/icinga/icinga-type.conf index 473f4b938..706b2d7cf 100644 --- a/lib/icinga/icinga-type.conf +++ b/lib/icinga/icinga-type.conf @@ -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", diff --git a/lib/icinga/service-notification.cpp b/lib/icinga/service-notification.cpp index 0f32995d1..0d69ab7bd 100644 --- a/lib/icinga/service-notification.cpp +++ b/lib/icinga/service-notification.cpp @@ -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); } diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index 3a45529c2..e985c2a18 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -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); diff --git a/lib/icinga/service.ti b/lib/icinga/service.ti index 134a41c61..09c5d3f13 100644 --- a/lib/icinga/service.ti +++ b/lib/icinga/service.ti @@ -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(); }}} }; - [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;