]> granicus.if.org Git - icinga2/commitdiff
Implement override_enable_notifications.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 26 Nov 2013 10:18:05 +0000 (11:18 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 26 Nov 2013 11:33:10 +0000 (12:33 +0100)
Refs #4746

lib/icinga/icinga-type.conf
lib/icinga/service-notification.cpp
lib/icinga/service.cpp
lib/icinga/service.ti

index 473f4b9383bcfce74ddeeed12f6595861659c927..706b2d7cf131441adc87e71312fb8cbce32d8f57 100644 (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",
index 0f32995d1702fc0f7aa6652adac5187f875582ce..0d69ab7bd56f389bae7b6e0805f2d97398af96b7 100644 (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);
 }
index 3a45529c2ccc56548e6bfa0464332913be1b9305..e985c2a187689dcd9f18de022c4f722ea69f5eae 100644 (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);
 
index 134a41c61db142e46814de370fea1f811c719a62..09c5d3f13d84b2a19c5dd4ff38ef475332b6fc1c 100644 (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;