]> granicus.if.org Git - icinga2/commitdiff
Implement notification_*_filter variables for Host/Service objects.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 26 Jun 2013 07:50:04 +0000 (09:50 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 26 Jun 2013 08:19:00 +0000 (10:19 +0200)
etc/icinga2/icinga2.conf.dist
lib/icinga/host.cpp
lib/icinga/icinga-type.conf
lib/icinga/notification.cpp
lib/icinga/notification.h
lib/icinga/service-notification.cpp
lib/icinga/user.cpp
lib/icinga/user.h

index 1a9986e464398e8c63bd77d25b77631e07d1f2d7..7bba49fa02530a0a50517885e1dbaa7446429c28 100644 (file)
@@ -32,7 +32,7 @@ local object CompatComponent "compat" { }
  */
 object Host "localhost" {
   services["ping4"] = { templates = [ "ping4" ] },
-  services["ping4"] = { templates = [ "ping4" ] }, 
+  services["ping6"] = { templates = [ "ping6" ] }, 
   services["http"] = { templates = [ "http_ip" ] }, 
   services["ssh"] = { templates = [ "ssh" ] }, 
   services["load"] = { templates = [ "load" ] }, 
index 9435187baf44e92ccd1ec4af0e74b3aef17c08b0..0d6381682a784cee30d19cc10b03497af00832ac 100644 (file)
@@ -224,6 +224,8 @@ void Host::UpdateSlaveServices(void)
                        keys.insert("servicegroups");
                        keys.insert("checkers");
                        keys.insert("notification_interval");
+                       keys.insert("notification_type_filter");
+                       keys.insert("notification_state_filter");
                        keys.insert("check_period");
                        keys.insert("servicedependencies");
                        keys.insert("hostdependencies");
index bac85be1bacc54d576fabda2e3e62fbd59142ef1..7acf132fcef2e6f06fbbed7405a1a9ba35ef4f59 100644 (file)
@@ -99,6 +99,9 @@ type Host {
                                                %attribute number "begin",
                                                %attribute number "end",
                                        },
+
+                                       %attribute number "notification_type_filter",
+                                       %attribute number "notification_state_filter"
                                }
                        },
                }
@@ -125,6 +128,9 @@ type Host {
                                %attribute number "begin",
                                %attribute number "end",
                        },
+
+                       %attribute number "notification_type_filter",
+                       %attribute number "notification_state_filter"
                }
        },
 
@@ -137,6 +143,9 @@ type Host {
        %attribute number "notification_interval",
        %attribute name(TimePeriod) "notification_period",
 
+       %attribute number "notification_type_filter",
+       %attribute number "notification_state_filter"
+
        %attribute dictionary "macros" {
                %attribute string "*"
        },
@@ -231,8 +240,8 @@ type Service {
                                %attribute number "end",
                        },
 
-                       %attribute number "type_filter",
-                       %attribute number "state_filter"
+                       %attribute number "notification_type_filter",
+                       %attribute number "notification_state_filter"
                }
        }
 }
@@ -307,8 +316,8 @@ type Notification {
        %attribute number "notification_interval",
        %attribute name(TimePeriod) "notification_period",
 
-       %attribute number "type_filter",
-       %attribute number "state_filter"
+       %attribute number "notification_type_filter",
+       %attribute number "notification_state_filter"
 }
 
 type User {
@@ -322,8 +331,8 @@ type User {
                %attribute name(UserGroup) "*"
        },
 
-       %attribute number "type_filter",
-       %attribute number "state_filter"
+       %attribute number "notification_type_filter",
+       %attribute number "notification_state_filter"
 
 }
 
index 9329e98c87d9449b827bb0571c12a13c9b7206cf..9460f8fddea319e895f4826e6e7560a92e5b7519 100644 (file)
@@ -46,8 +46,8 @@ Notification::Notification(const Dictionary::Ptr& serializedUpdate)
        RegisterAttribute("users", Attribute_Config, &m_Users);
        RegisterAttribute("groups", Attribute_Config, &m_Groups);
        RegisterAttribute("times", Attribute_Config, &m_Times);
-       RegisterAttribute("type_filter", Attribute_Config, &m_TypeFilter);
-       RegisterAttribute("state_filter", Attribute_Config, &m_StateFilter);
+       RegisterAttribute("notification_type_filter", Attribute_Config, &m_NotificationTypeFilter);
+       RegisterAttribute("notification_state_filter", Attribute_Config, &m_NotificationStateFilter);
        RegisterAttribute("host_name", Attribute_Config, &m_HostName);
        RegisterAttribute("service", Attribute_Config, &m_Service);
        RegisterAttribute("export_macros", Attribute_Config, &m_ExportMacros);
@@ -142,20 +142,20 @@ Dictionary::Ptr Notification::GetTimes(void) const
        return m_Times;
 }
 
-unsigned long Notification::GetTypeFilter(void) const
+unsigned long Notification::GetNotificationTypeFilter(void) const
 {
-       if (m_TypeFilter.IsEmpty())
+       if (m_NotificationTypeFilter.IsEmpty())
                return ~(unsigned long)0; /* All states. */
        else
-               return m_TypeFilter;
+               return m_NotificationTypeFilter;
 }
 
-unsigned long Notification::GetStateFilter(void) const
+unsigned long Notification::GetNotificationStateFilter(void) const
 {
-       if (m_StateFilter.IsEmpty())
+       if (m_NotificationStateFilter.IsEmpty())
                return ~(unsigned long)0; /* All states. */
        else
-               return m_StateFilter;
+               return m_NotificationStateFilter;
 }
 
 double Notification::GetNotificationInterval(void) const
@@ -260,18 +260,16 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction
 
                unsigned long ftype = 1 << type;
 
-               Log(LogDebug, "icinga", "FType=" + Convert::ToString(ftype) + ", TypeFilter=" + Convert::ToString(GetTypeFilter()));
+               Log(LogDebug, "icinga", "FType=" + Convert::ToString(ftype) + ", TypeFilter=" + Convert::ToString(GetNotificationTypeFilter()));
 
-               if (!(ftype & GetTypeFilter())) {
+               if (!(ftype & GetNotificationTypeFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': type filter does not match");
                        return;
                }
 
                unsigned long fstate = 1 << GetService()->GetState();
 
-               Log(LogDebug, "icinga", "FState=" + Convert::ToString(fstate) + ", StateFilter=" + Convert::ToString(GetStateFilter()));
-
-               if (!(fstate & GetStateFilter())) {
+               if (!(fstate & GetNotificationStateFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': state filter does not match");
                        return;
                }
@@ -314,7 +312,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
 
                unsigned long ftype = 1 << type;
 
-               if (!(ftype & user->GetTypeFilter())) {
+               if (!(ftype & user->GetNotificationTypeFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
                            GetName() + " and user '" + user->GetName() + "': type filter does not match");
                        return;
@@ -322,7 +320,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
 
                unsigned long fstate = 1 << GetService()->GetState();
 
-               if (!(fstate & user->GetStateFilter())) {
+               if (!(fstate & user->GetNotificationStateFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
                            GetName() + " and user '" + user->GetName() + "': state filter does not match");
                        return;
index 6fa736253f5eca32e3a5724169c463c7f8de1976..c13b200ce9e6a664ac9d052c8f1d866ef7ab53b3 100644 (file)
@@ -75,8 +75,8 @@ public:
        std::set<User::Ptr> GetUsers(void) const;
        std::set<UserGroup::Ptr> GetGroups(void) const;
        Dictionary::Ptr GetTimes(void) const;
-       unsigned long GetTypeFilter(void) const;
-       unsigned long GetStateFilter(void) const;
+       unsigned long GetNotificationTypeFilter(void) const;
+       unsigned long GetNotificationStateFilter(void) const;
 
        double GetLastNotification(void) const;
        void SetLastNotification(double time);
@@ -104,8 +104,8 @@ private:
        Attribute<Array::Ptr> m_Users;
        Attribute<Array::Ptr> m_Groups;
        Attribute<Dictionary::Ptr> m_Times;
-       Attribute<long> m_TypeFilter;
-       Attribute<long> m_StateFilter;
+       Attribute<long> m_NotificationTypeFilter;
+       Attribute<long> m_NotificationStateFilter;
        Attribute<String> m_HostName;
        Attribute<String> m_Service;
 
index e7c6eb478845c8ec6274a646b9ea0bc9372a023e..7939a9bd4bac8a1f64e01a1e353e53837e994515 100644 (file)
@@ -243,6 +243,8 @@ void Service::UpdateSlaveNotifications(void)
                        keys.insert("groups");
                        keys.insert("notification_interval");
                        keys.insert("notification_period");
+                       keys.insert("notification_type_filter");
+                       keys.insert("notification_state_filter");
                        keys.insert("export_macros");
 
                        ExpressionList::Ptr svc_exprl = boost::make_shared<ExpressionList>();
index 2b740963a17cca995049bb5ecf42f8ee0c311717..53e297670f96992b478c7cae19ec15c54cb6fae6 100644 (file)
@@ -34,8 +34,8 @@ User::User(const Dictionary::Ptr& serializedUpdate)
        RegisterAttribute("macros", Attribute_Config, &m_Macros);
        RegisterAttribute("groups", Attribute_Config, &m_Groups);
        RegisterAttribute("notification_period", Attribute_Config, &m_NotificationPeriod);
-       RegisterAttribute("type_filter", Attribute_Config, &m_TypeFilter);
-       RegisterAttribute("state_filter", Attribute_Config, &m_StateFilter);
+       RegisterAttribute("notification_type_filter", Attribute_Config, &m_NotificationTypeFilter);
+       RegisterAttribute("notification_state_filter", Attribute_Config, &m_NotificationStateFilter);
 }
 
 User::~User(void)
@@ -81,20 +81,20 @@ TimePeriod::Ptr User::GetNotificationPeriod(void) const
        return TimePeriod::GetByName(m_NotificationPeriod);
 }
 
-unsigned long User::GetTypeFilter(void) const
+unsigned long User::GetNotificationTypeFilter(void) const
 {
-       if (m_TypeFilter.IsEmpty())
+       if (m_NotificationTypeFilter.IsEmpty())
                return ~(unsigned long)0; /* All states. */
        else
-               return m_TypeFilter;
+               return m_NotificationTypeFilter;
 }
 
-unsigned long User::GetStateFilter(void) const
+unsigned long User::GetNotificationStateFilter(void) const
 {
-       if (m_StateFilter.IsEmpty())
+       if (m_NotificationStateFilter.IsEmpty())
                return ~(unsigned long)0; /* All states. */
        else
-               return m_StateFilter;
+               return m_NotificationStateFilter;
 }
 
 bool User::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
index 855a8ecdc21bb049ff0e8adeebcd6953ab149f4c..cad26ad7a2c1f90d54e979568a20d869551ed1ba 100644 (file)
@@ -48,8 +48,8 @@ public:
        String GetDisplayName(void) const;
        Array::Ptr GetGroups(void) const;
        TimePeriod::Ptr GetNotificationPeriod(void) const;
-       unsigned long GetTypeFilter(void) const;
-       unsigned long GetStateFilter(void) const;
+       unsigned long GetNotificationTypeFilter(void) const;
+       unsigned long GetNotificationStateFilter(void) const;
 
        Dictionary::Ptr GetMacros(void) const;
 
@@ -63,8 +63,8 @@ private:
        Attribute<Dictionary::Ptr> m_Macros;
        Attribute<String> m_NotificationPeriod;
        Attribute<Array::Ptr> m_Groups;
-       Attribute<long> m_TypeFilter;
-       Attribute<long> m_StateFilter;
+       Attribute<long> m_NotificationTypeFilter;
+       Attribute<long> m_NotificationStateFilter;
 };
 
 }