]> granicus.if.org Git - icinga2/commitdiff
Rename the notification attributes.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 9 Apr 2014 08:25:23 +0000 (10:25 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 9 Apr 2014 08:25:23 +0000 (10:25 +0200)
Fixes #5906

22 files changed:
components/livestatus/contactstable.cpp
components/livestatus/statehisttable.cpp
components/notification/notificationcomponent.cpp
doc/3.04-notifications.md
doc/3.07-time-periods.md
doc/4.3-object-types.md
doc/6.09-volatile-services.md
doc/8-differences-between-icinga-1x-and-2.md
etc/icinga2/conf.d/notifications.conf
etc/icinga2/conf.d/users.conf
lib/db_ido/userdbobject.cpp
lib/icinga/compatutility.cpp
lib/icinga/dependency.cpp
lib/icinga/dependency.ti
lib/icinga/icinga-type.conf
lib/icinga/notification.cpp
lib/icinga/notification.h
lib/icinga/notification.ti
lib/icinga/user.cpp
lib/icinga/user.h
lib/icinga/user.ti
lib/methods/pluginnotificationtask.cpp

index bf4653237dd8504d78d01baaa74cae21563fce7f..12d9397e8a797d0f2239ac3ed15ab1010711944e 100644 (file)
@@ -124,7 +124,7 @@ Value ContactsTable::HostNotificationPeriodAccessor(const Value& row)
                return Empty;
 
        /* same as service */
-       TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+       TimePeriod::Ptr timeperiod = user->GetPeriod();
 
        if (!timeperiod)
                return Empty;
@@ -139,7 +139,7 @@ Value ContactsTable::ServiceNotificationPeriodAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+       TimePeriod::Ptr timeperiod = user->GetPeriod();
 
        if (!timeperiod)
                return Empty;
@@ -174,7 +174,7 @@ Value ContactsTable::InHostNotificationPeriodAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+       TimePeriod::Ptr timeperiod = user->GetPeriod();
 
        if (!timeperiod)
                return Empty;
@@ -189,7 +189,7 @@ Value ContactsTable::InServiceNotificationPeriodAccessor(const Value& row)
        if (!user)
                return Empty;
 
-       TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+       TimePeriod::Ptr timeperiod = user->GetPeriod();
 
        if (!timeperiod)
                return Empty;
index 484d52100d1d2759c54c47fab5f6f7ff4f934113..6ee9e091c157c888cdcb6e48e96632a139592d80 100644 (file)
@@ -128,7 +128,7 @@ void StateHistTable::UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, in
                bool in_notification_period = true;
                String notification_period_name;
                BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
-                       TimePeriod::Ptr notification_period = notification->GetNotificationPeriod();
+                       TimePeriod::Ptr notification_period = notification->GetPeriod();
 
                        if (notification_period) {
                                if (notification_period->IsInside(static_cast<double>(time)))
index 7982f28344a6216b48b95de3531ce8c99be68bda..80b541534e422cf9ac3716246be198ee2b061d1c 100644 (file)
@@ -74,7 +74,7 @@ void NotificationComponent::NotificationTimerHandler(void)
        BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjects<Notification>()) {
                Checkable::Ptr checkable = notification->GetCheckable();
 
-               if (notification->GetNotificationInterval() <= 0 && notification->GetLastProblemNotification() < checkable->GetLastHardStateChange())
+               if (notification->GetInterval() <= 0 && notification->GetLastProblemNotification() < checkable->GetLastHardStateChange())
                        continue;
 
                if (notification->GetNextNotification() > now)
@@ -84,7 +84,7 @@ void NotificationComponent::NotificationTimerHandler(void)
 
                {
                        ObjectLock olock(notification);
-                       notification->SetNextNotification(Utility::GetTime() + notification->GetNotificationInterval());
+                       notification->SetNextNotification(Utility::GetTime() + notification->GetInterval());
                }
 
                {
index 188df926ffd00f46ba5e22dc087b68b41d18c869..556d7d4158acaa514f31e3fd9c561f928a2c01bc 100644 (file)
@@ -18,17 +18,15 @@ The user `icingaadmin` in the example below will get notified only on `WARNING`
     
     object User "icingaadmin" {
       display_name = "Icinga 2 Admin"
-      enable_notifications = 1
-      notification_state_filter = [ OK, Warning, Critical ]
-      notification_type_filter = [ Problem, Recovery ]
-      vars.email = "icinga@localhost"
-      vars.pager = "+49123456789"
-      }
+      enable_notifications = true
+      states = [ OK, Warning, Critical ]
+      types = [ Problem, Recovery ]
+      email = "icinga@localhost"
     }
 
-If you don't set the `notification_state_filter` and `notification_type_filter`
-configuration attributes for the `User` object, all states and types will be
-notified.
+If you don't set the `states` and `types`
+configuration attributes for the `User` object, notifications for all states and types
+will be sent.
 
 You should choose which information you (and your notified users) are interested in
 case of emergency, and also which information does not provide any value to you and
@@ -70,15 +68,15 @@ to the defined notifications. That way you'll save duplicated attributes in each
 TODO
 
     template Notification "generic-notification" {
-      notification_interval = 15m
+      interval = 15m
     
-      notification_command = "mail-service-notification"
+      _command = "mail-service-notification"
   
-      notification_state_filter = [ Warning, Critical, Unknown ]
-      notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
+      states = [ Warning, Critical, Unknown ]
+      types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
                                    FlappingEnd, DowntimeStart,DowntimeEnd, DowntimeRemoved ]
   
-      notification_period = "24x7"
+      period = "24x7"
     }
     
 The time period `24x7` is shipped as example configuration with Icinga 2.
@@ -88,7 +86,7 @@ Use the `apply` keyword to create `Notification` objects for your services:
     apply Notification "mail" to Service {
       import "generic-notification"
   
-      notification_command = "mail-notification"
+      command = "mail-notification"
       users = [ "icingaadmin" ]
 
       assign where service.name == "mysql"
@@ -108,7 +106,7 @@ if not already solved.
 You can define notification start and end times as additional configuration
 attributes making the `Notification` object a so-called `notification escalation`.
 Using templates you can share the basic notification attributes such as users or the
-`notification_interval` (and override them for the escalation then).
+`interval` (and override them for the escalation then).
 
 Using the example from above, you can define additional users being escalated for sms
 notifications between start and end time.
@@ -147,7 +145,7 @@ command) after `30m` until `1h`.
 
 > **Note**
 >
-> The `notification_interval` was set to 15m in the `generic-notification`
+> The `interval` was set to 15m in the `generic-notification`
 > template example. Lower that value in your escalations by using a secondary
 > template or overriding the attribute directly in the `notifications` array
 > position for `escalation-sms-2nd-level`.
@@ -158,7 +156,7 @@ notified, but only for one hour (`2h` as `end` key for the `times` dictionary).
 
     apply Notification "mail" to Service {
       import "generic-notification"
-      notification_command = "mail-notification"
+      command = "mail-notification"
       users = [ "icingaadmin" ]
   
       assign where service.name == "ping4"
@@ -166,7 +164,7 @@ notified, but only for one hour (`2h` as `end` key for the `times` dictionary).
 
     apply Notification "escalation-sms-2nd-level" to Service {
       import "generic-notification"
-      notification_command = "sms-notification"
+      command = "sms-notification"
       users = [ "icinga-oncall-2nd-level" ]
           
       times = {
@@ -179,7 +177,7 @@ notified, but only for one hour (`2h` as `end` key for the `times` dictionary).
 
     apply Notification "escalation-sms-1st-level" to Service {
       import "generic-notification"
-      notification_command = "sms-notification"
+      command = "sms-notification"
       users = [ "icinga-oncall-1st-level" ]
           
       times = {
@@ -205,7 +203,7 @@ end time for this notification.
 
     apply Notification "mail" to Service {
       import "generic-notification"
-      notification_command = "mail-notification"
+      command = "mail-notification"
       users = [ "icingaadmin" ]
           
       times.begin = 15m // delay first notification
@@ -222,9 +220,9 @@ Available state and type filters for notifications are:
 
     template Notification "generic-notification" {
   
-      notification_state_filter = [ Warning, Critical, Unknown ]
-      notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
-                                   FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
+      states = [ Warning, Critical, Unknown ]
+      types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
+                FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
     }
 
 If you are familiar with Icinga 1.x `notification_options` please note that they have been split
index 7c8b8e233e0d684f7e587fd65d6fbb7aa2e2a869..023f708f82f4b8968e0935e203d2127d476255ce 100644 (file)
@@ -3,8 +3,8 @@
 Time Periods define time ranges in Icinga where event actions are
 triggered, for example if a service check is executed or not within
 the `check_period` attribute. Or a notification should be sent to
-users or not, filtered by the `notification_period` configuration
-attribute for `Notification` and `User` objects.
+users or not, filtered by the `period` and `notification_period`
+configuration attributes for `Notification` and `User` objects.
 
 > **Note**
 >
@@ -63,7 +63,7 @@ create a new timeperiod named `workhours` defining a work day with
       }
     }
 
-Use the `notification_period` attribute to assign time periods to
+Use the `period` attribute to assign time periods to
 `Notification` objects:
 
     object Notification "mail" {
@@ -71,7 +71,7 @@ Use the `notification_period` attribute to assign time periods to
 
       host_name = "localhost"
 
-      notification_command = "mail-notification"
+      command = "mail-notification"
       users = [ "icingaadmin" ]
-      notification_period = "workhours"
+      period = "workhours"
     }
index c8233f5a4049da97b550b28c900d11a6c4cbb96f..334d63062536f369f4842cd01374fcd66a79113a 100644 (file)
@@ -131,11 +131,11 @@ Example:
       host_name = "localhost"
       service_name = "ping4"
 
-      notification_command = "mail-notification"
+      command = "mail-notification"
 
       users = [ "user1", "user2" ]
 
-      notification_type_filter = [ Problem, Recovery ]
+      types = [ Problem, Recovery ]
     }
 
 Attributes:
@@ -148,11 +148,11 @@ Attributes:
   users                     | **Optional.** A list of user names who should be notified.
   user_groups               | **Optional.** A list of user group names who should be notified.
   times                     | **Optional.** A dictionary containing `begin` and `end` attributes for the notification.
-  notification_command      | **Required.** The name of the notification command which should be executed when the notification is triggered.
-  notification_interval     | **Optional.** The notification interval (in seconds). This interval is used for active notifications. Defaults to 30 minutes. 
-  notification_period       | **Optional.** The name of a time period which determines when this notification should be triggered. Not set by default.
-  notification_type_filter  | **Optional.** A list of state filters when this notification should be triggered. By default everything is matched.
-  notification_state_filter | **Optional.** A list of type filters when this notification should be triggered. By default everything is matched.
+  command                   | **Required.** The name of the notification command which should be executed when the notification is triggered.
+  interval                  | **Optional.** The notification interval (in seconds). This interval is used for active notifications. Defaults to 30 minutes. 
+  period                    | **Optional.** The name of a time period which determines when this notification should be triggered. Not set by default.
+  types                     | **Optional.** A list of type filters when this notification should be triggered. By default everything is matched.
+  states                    | **Optional.** A list of type filters when this notification should be triggered. By default everything is matched.
 
 Available notification state filters:
 
@@ -235,11 +235,10 @@ Example:
       display_name = "Icinga 2 Admin"
       groups = [ "icingaadmins" ]
 
-      enable_notifications = 1
-      notification_period = "24x7"
+      notificcation_period = "24x7"
 
-      notification_state_filter = [ OK, Warning, Critical, Unknown ]
-      notification_type_filter = [ Problem, Recovery ]
+      states = [ OK, Warning, Critical, Unknown ]
+      types = [ Problem, Recovery ]
 
       vars = {
         name = "Icinga 2 Admin"
@@ -281,9 +280,9 @@ Attributes:
   vars            |**Optional.** A dictionary containing custom attributes that are specific to this user.
   groups          |**Optional.** An array of group names.
   enable_notifications|**Optional.** Whether notifications are enabled for this user.
-  notification_period|**Optional.** The name of a time period which determines when this notification should be triggered. Not set by default.
-  notification_type_filter|**Optional.** A set of state filters when this notification should be triggered. By default everything is matched.
-  notification_state_filter|**Optional.** A set of type filters when this notification should be triggered. By default everything is matched.
+  period          |**Optional.** The name of a time period which determines when this notification should be triggered. Not set by default.
+  types           |**Optional.** A set of type filters when this notification should be triggered. By default everything is matched.
+  states          |**Optional.** A set of state filters when this notification should be triggered. By default everything is matched.
 
 ### <a id="objecttype-usergroup"></a> UserGroup
 
@@ -523,8 +522,8 @@ Example:
 
       service_perfdata_path = "/var/spool/icinga2/perfdata/service-perfdata"
 
-      host_format_template = "DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.checkcommand$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.statetype$"
-      service_format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.description$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.checkcommand$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.statetype$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.statetype$"
+      host_format_template = "DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$"
+      service_format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$"
 
       rotation_interval = 15s
     }
index 3cf0b5e2b1fc027882fe0531de2b99ad29f7c44b..142ace790cecf4c982004d8d1dc71fbd5a86497e 100644 (file)
@@ -4,9 +4,9 @@ By default all services remain in a non-volatile state. When a problem
 occurs, the `SOFT` state applies and once `max_check_attempts` attribute
 is reached with the check counter, a `HARD` state transition happens.
 Notifications are only triggered by `HARD` state changes and are then
-re-sent defined by the `notification_interval` attribute.
+re-sent defined by the `interval` attribute.
 
 It may be reasonable to have a volatile service which stays in a `HARD`
 state type if the service stays in a `NOT-OK` state. That way each
 service recheck will automatically trigger a notification unless the
-service is acknowledged or in a scheduled downtime.
\ No newline at end of file
+service is acknowledged or in a scheduled downtime.
index 52af7d8827fb4a683b45ead105fa4c1fe233365b..de30a9703291e6c13cec34bb731782944fc33732 100644 (file)
@@ -445,13 +445,13 @@ Icinga 2 attempts to solve that problem in this way
 
 * Create user X, set SMS and Mail attributes, used for authorization
 * Create user Y, set SMS and Mail attributes, used for authorization
-* Create notification A-SMS, set notification_command for sms, add user X,
+* Create notification A-SMS, set command for sms, add user X,
   assign notification A-SMS to service A
-* Create notification B-Mail, set notification_command for mail, add user X,
+* Create notification B-Mail, set command for mail, add user X,
   assign notification Mail to service B
-* Create notification C-SMS, set notification_command for sms, add user Y,
+* Create notification C-SMS, set command for sms, add user Y,
   assign notification C-SMS to service C
-* Create notification C-Mail, set notification_command for mail, add user Y,
+* Create notification C-Mail, set command for mail, add user Y,
   assign notification C-Mail to service C
 
 Previously in Icinga 1.x it looked like this:
@@ -497,8 +497,8 @@ All state and type filter use long names or'd with a pipe together
 
     notification_options w,u,c,r,f,s
 
-    notification_state_filter = [ Warning, Unknown, Critical ]
-    notification_type_filter = [ Problem, Recovery, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
+    states = [ Warning, Unknown, Critical ]
+    filters = [ Problem, Recovery, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
 
 Icinga 2 adds more fine-grained type filters for acknowledgements, downtime
 and flapping type (start, end, ...).
index 3101d322182b8c6e93f0ac8c6d9341bda28ee089..747a232b38baf57a42c9c1720a27fdcd8580bfc8 100644 (file)
@@ -3,14 +3,14 @@
  */
 
 template Notification "mail-host-notification" {
-  notification_command = "mail-host-notification"
+  command = "mail-host-notification"
 
-  notification_state_filter = [ Up, Down ]
-  notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom,
-                               FlappingStart, FlappingEnd,
-                               DowntimeStart, DowntimeEnd, DowntimeRemoved ]
+  states = [ Up, Down ]
+  types = [ Problem, Acknowledgement, Recovery, Custom,
+            FlappingStart, FlappingEnd,
+            DowntimeStart, DowntimeEnd, DowntimeRemoved ]
 
-  notification_period = "24x7"
+  period = "24x7"
 }
 
 object NotificationCommand "mail-host-notification" {
@@ -33,14 +33,14 @@ object NotificationCommand "mail-host-notification" {
 }
 
 template Notification "mail-service-notification" {
-  notification_command = "mail-service-notification"
+  command = "mail-service-notification"
 
-  notification_state_filter = [ OK, Warning, Critical, Unknown ]
-  notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom,
-                               FlappingStart, FlappingEnd,
-                               DowntimeStart, DowntimeEnd, DowntimeRemoved ]
+  states = [ OK, Warning, Critical, Unknown ]
+  types = [ Problem, Acknowledgement, Recovery, Custom,
+            FlappingStart, FlappingEnd,
+            DowntimeStart, DowntimeEnd, DowntimeRemoved ]
 
-  notification_period = "24x7"
+  period = "24x7"
 }
 
 object NotificationCommand "mail-service-notification" {
index faa22dfb5d1f2804d6a03210c9c83de6e40ec52c..515ef218379108097eaec693938de7d98f19f9a1 100644 (file)
@@ -10,7 +10,6 @@ object User "icingaadmin" {
   groups = [ "icingaadmins" ]
 
   email = "icinga@localhost"
-  pager = "icingaadmin@localhost.localdomain"
 }
 
 object UserGroup "icingaadmins" {
index 01389bcb4db47a6010fb175c1b9a58e3fa9f971b..8d536065212dee0dad79990e5a6e8dad89bf52b1 100644 (file)
@@ -49,22 +49,22 @@ Dictionary::Ptr UserDbObject::GetConfigFields(void) const
                fields->Set("pager_address", vars->Get("pager"));
        }
 
-       fields->Set("host_timeperiod_object_id", user->GetNotificationPeriod());
-       fields->Set("service_timeperiod_object_id", user->GetNotificationPeriod());
+       fields->Set("host_timeperiod_object_id", user->GetPeriod());
+       fields->Set("service_timeperiod_object_id", user->GetPeriod());
        fields->Set("host_notifications_enabled", user->GetEnableNotifications());
        fields->Set("service_notifications_enabled", user->GetEnableNotifications());
        fields->Set("can_submit_commands", 1);
-       fields->Set("notify_service_recovery", user->GetNotificationStateFilter() & NotificationRecovery);
-       fields->Set("notify_service_warning", user->GetNotificationStateFilter() & NotificationProblem);
-       fields->Set("notify_service_unknown", user->GetNotificationStateFilter() & NotificationProblem);
-       fields->Set("notify_service_critical", user->GetNotificationStateFilter() & NotificationProblem);
-       fields->Set("notify_service_flapping", user->GetNotificationStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd));
-       fields->Set("notify_service_downtime", user->GetNotificationStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved));
-       fields->Set("notify_host_recovery", user->GetNotificationStateFilter() & NotificationRecovery);
-       fields->Set("notify_host_down", user->GetNotificationStateFilter() & NotificationProblem);
-       fields->Set("notify_host_unreachable", user->GetNotificationStateFilter() & NotificationProblem);
-       fields->Set("notify_host_flapping", user->GetNotificationStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd));
-       fields->Set("notify_host_downtime", user->GetNotificationStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved));
+       fields->Set("notify_service_recovery", (user->GetStateFilter() & NotificationRecovery) != 0);
+       fields->Set("notify_service_warning", (user->GetStateFilter() & NotificationProblem) != 0);
+       fields->Set("notify_service_unknown", (user->GetStateFilter() & NotificationProblem) != 0);
+       fields->Set("notify_service_critical", (user->GetStateFilter() & NotificationProblem) != 0);
+       fields->Set("notify_service_flapping", (user->GetStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd)) != 0);
+       fields->Set("notify_service_downtime", (user->GetStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0);
+       fields->Set("notify_host_recovery", (user->GetStateFilter() & NotificationRecovery) != 0);
+       fields->Set("notify_host_down", (user->GetStateFilter() & NotificationProblem) != 0);
+       fields->Set("notify_host_unreachable", (user->GetStateFilter() & NotificationProblem) != 0);
+       fields->Set("notify_host_flapping", (user->GetStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd)) != 0);
+       fields->Set("notify_host_downtime", (user->GetStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0);
 
        return fields;
 }
index 40c7d244ec47d3e4567d296a64c2ee7bd40a31bc..8b782fcfc61224fd185adee887312f75055eb2fd 100644 (file)
@@ -354,7 +354,7 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
        BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
                ObjectLock olock(notification);
 
-               TimePeriod::Ptr timeperiod = notification->GetNotificationPeriod();
+               TimePeriod::Ptr timeperiod = notification->GetPeriod();
 
                /* first notification wins */
                if (timeperiod)
@@ -487,8 +487,8 @@ double CompatUtility::GetCheckableNotificationNotificationInterval(const Checkab
        double notification_interval = -1;
 
        BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
-               if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
-                       notification_interval = notification->GetNotificationInterval();
+               if (notification_interval == -1 || notification->GetInterval() < notification_interval)
+                       notification_interval = notification->GetInterval();
        }
 
        if (notification_interval == -1)
@@ -505,8 +505,8 @@ String CompatUtility::GetCheckableNotificationNotificationPeriod(const Checkable
 
        BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
 
-               if (notification->GetNotificationPeriod())
-                       notification_period = notification->GetNotificationPeriod();
+               if (notification->GetPeriod())
+                       notification_period = notification->GetPeriod();
        }
 
        if (!notification_period)
@@ -523,11 +523,8 @@ String CompatUtility::GetCheckableNotificationNotificationOptions(const Checkabl
        unsigned long notification_state_filter = 0;
 
        BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
-               if (notification->GetNotificationTypeFilter())
-                       notification_type_filter = notification->GetNotificationTypeFilter();
-
-               if (notification->GetNotificationStateFilter())
-                       notification_state_filter = notification->GetNotificationStateFilter();
+               notification_type_filter = notification->GetTypeFilter();
+               notification_state_filter = notification->GetStateFilter();
        }
 
        std::vector<String> notification_options;
@@ -569,8 +566,7 @@ int CompatUtility::GetCheckableNotificationTypeFilter(const Checkable::Ptr& chec
        BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
                ObjectLock olock(notification);
 
-               if (notification->GetNotificationTypeFilter())
-                       notification_type_filter = notification->GetNotificationTypeFilter();
+               notification_type_filter = notification->GetTypeFilter();
        }
 
        return notification_type_filter;
@@ -585,8 +581,7 @@ int CompatUtility::GetCheckableNotificationStateFilter(const Checkable::Ptr& che
        BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
                ObjectLock olock(notification);
 
-               if (notification->GetNotificationStateFilter())
-                       notification_state_filter = notification->GetNotificationStateFilter();
+               notification_state_filter = notification->GetStateFilter();
        }
 
        return notification_state_filter;
index bfc08c6540801017a4108335686d68e2e3ded973..679a605647f9d5d21c8111477b6ab0de036fb2bf 100644 (file)
@@ -55,7 +55,7 @@ void Dependency::OnConfigLoaded(void)
        else
                defaultFilter = StateFilterOK | StateFilterWarning;
 
-       SetStateFilter(FilterArrayToInt(GetStateFilterRaw(), defaultFilter));
+       SetStateFilter(FilterArrayToInt(GetStates(), defaultFilter));
 }
 
 void Dependency::OnStateLoaded(void)
index b77437972c7bfaa001e3f85aaddfb91ea30a5009..022157be82aa27fa0cfecc0cc1c64c7127fb55d5 100644 (file)
@@ -22,7 +22,7 @@ class Dependency : DynamicObject < DependencyNameComposer
 
        [config] String period (PeriodRaw);
 
-       [config] Array::Ptr state_filter (StateFilterRaw);
+       [config] Array::Ptr states;
        int state_filter_real (StateFilter);
 
        [config] bool disable_checks;
index 7bf57db97eda001b608dce670975b16a07d22233..455243371f0a70709cd00b3c360721f9d35f92d1 100644 (file)
                %attribute %number "end",
        },
 
-       %require "notification_command",
-       %attribute %name(NotificationCommand) "notification_command",
+       %require "command",
+       %attribute %name(NotificationCommand) "command",
 
-       %attribute %number "notification_interval",
-       %attribute %name(TimePeriod) "notification_period",
+       %attribute %number "interval",
+       %attribute %name(TimePeriod) "period",
 
-       %attribute %array "notification_type_filter" {
+       %attribute %array "types" {
                %attribute %number "*"
        },
-       %attribute %array "notification_state_filter" {
+       %attribute %array "states" {
                %attribute %number "*"
        },
 
        },
 
        %attribute %number "enable_notifications",
-       %attribute %array "notification_type_filter" {
+       %attribute %array "types" {
                %attribute %number "*"
        },
-       %attribute %array "notification_state_filter" {
+       %attribute %array "states" {
                %attribute %number "*"
        },
-       %attribute %name(TimePeriod) "notification_period",
+       %attribute %name(TimePeriod) "period",
 
        %attribute %string "email",
        %attribute %string "pager",
index dbd1b3a8db358ca23d58dcb03faddb17d69b0a74..0fb5254648f90d058e305c39d29a92946e353559 100644 (file)
@@ -78,8 +78,8 @@ void Notification::StaticInitialize(void)
 
 void Notification::OnConfigLoaded(void)
 {
-       SetNotificationTypeFilter(FilterArrayToInt(GetNotificationTypeFilterRaw(), ~0));
-       SetNotificationStateFilter(FilterArrayToInt(GetNotificationStateFilterRaw(), ~0));
+       SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
+       SetStateFilter(FilterArrayToInt(GetStates(), ~0));
 
        GetCheckable()->AddNotification(GetSelf());
 }
@@ -108,9 +108,9 @@ Checkable::Ptr Notification::GetCheckable(void) const
                return host->GetServiceByShortName(GetServiceName());
 }
 
-NotificationCommand::Ptr Notification::GetNotificationCommand(void) const
+NotificationCommand::Ptr Notification::GetCommand(void) const
 {
-       return NotificationCommand::GetByName(GetNotificationCommandRaw());
+       return NotificationCommand::GetByName(GetCommandRaw());
 }
 
 std::set<User::Ptr> Notification::GetUsers(void) const
@@ -157,9 +157,9 @@ std::set<UserGroup::Ptr> Notification::GetUserGroups(void) const
        return result;
 }
 
-TimePeriod::Ptr Notification::GetNotificationPeriod(void) const
+TimePeriod::Ptr Notification::GetPeriod(void) const
 {
-       return TimePeriod::GetByName(GetNotificationPeriodRaw());
+       return TimePeriod::GetByName(GetPeriodRaw());
 }
 
 double Notification::GetNextNotification(void) const
@@ -221,7 +221,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
        Checkable::Ptr checkable = GetCheckable();
 
        if (!force) {
-               TimePeriod::Ptr tp = GetNotificationPeriod();
+               TimePeriod::Ptr tp = GetPeriod();
 
                if (tp && !tp->IsInside(Utility::GetTime())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': not in timeperiod");
@@ -245,9 +245,9 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
 
                unsigned long ftype = 1 << type;
 
-               Log(LogDebug, "icinga", "FType=" + Convert::ToString(ftype) + ", TypeFilter=" + Convert::ToString(GetNotificationTypeFilter()));
+               Log(LogDebug, "icinga", "FType=" + Convert::ToString(ftype) + ", TypeFilter=" + Convert::ToString(GetTypeFilter()));
 
-               if (!(ftype & GetNotificationTypeFilter())) {
+               if (!(ftype & GetTypeFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': type filter does not match");
                        return;
                }
@@ -263,7 +263,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
                else
                        fstate = HostStateToFilter(host->GetState());
 
-               if (!(fstate & GetNotificationStateFilter())) {
+               if (!(fstate & GetStateFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': state filter does not match");
                        return;
                }
@@ -312,7 +312,7 @@ bool Notification::CheckNotificationUserFilters(NotificationType type, const Use
        ASSERT(!OwnsLock());
 
        if (!force) {
-               TimePeriod::Ptr tp = user->GetNotificationPeriod();
+               TimePeriod::Ptr tp = user->GetPeriod();
 
                if (tp && !tp->IsInside(Utility::GetTime())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
@@ -322,7 +322,7 @@ bool Notification::CheckNotificationUserFilters(NotificationType type, const Use
 
                unsigned long ftype = 1 << type;
 
-               if (!(ftype & user->GetNotificationTypeFilter())) {
+               if (!(ftype & user->GetTypeFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
                            GetName() + " and user '" + user->GetName() + "': type filter does not match");
                        return false;
@@ -340,7 +340,7 @@ bool Notification::CheckNotificationUserFilters(NotificationType type, const Use
                else
                                fstate = HostStateToFilter(host->GetState());
 
-               if (!(fstate & user->GetNotificationStateFilter())) {
+               if (!(fstate & user->GetStateFilter())) {
                        Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
                            GetName() + " and user '" + user->GetName() + "': state filter does not match");
                        return false;
@@ -355,7 +355,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
        ASSERT(!OwnsLock());
 
        try {
-               NotificationCommand::Ptr command = GetNotificationCommand();
+               NotificationCommand::Ptr command = GetCommand();
 
                if (!command) {
                        Log(LogDebug, "icinga", "No notification_command found for notification '" + GetName() + "'. Skipping execution.");
@@ -451,18 +451,3 @@ void Notification::ValidateFilters(const String& location, const Dictionary::Ptr
        }
 }
 
-bool Notification::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
-{
-       Dictionary::Ptr vars = GetVars();
-
-       if (macro.SubStr(0, 13) == "notification.") {
-               String key = vars->Get(macro.SubStr(13));
-
-               if (vars && vars->Contains(key)) {
-                       *result = vars->Get(key);
-                       return true;
-               }
-       }
-
-       return false;
-}
index 32f4363990b6f82d52382d0b6cff134b290ee346..3cd25217575cedd8bba247c31cf6b4e7b63ae57f 100644 (file)
@@ -71,7 +71,7 @@ class Checkable;
  *
  * @ingroup icinga
  */
-class I2_ICINGA_API Notification : public ObjectImpl<Notification>, public MacroResolver
+class I2_ICINGA_API Notification : public ObjectImpl<Notification>
 {
 public:
        DECLARE_PTR_TYPEDEFS(Notification);
@@ -80,8 +80,8 @@ public:
        static void StaticInitialize(void);
 
        shared_ptr<Checkable> GetCheckable(void) const;
-       shared_ptr<NotificationCommand> GetNotificationCommand(void) const;
-       TimePeriod::Ptr GetNotificationPeriod(void) const;
+       shared_ptr<NotificationCommand> GetCommand(void) const;
+       TimePeriod::Ptr GetPeriod(void) const;
        std::set<User::Ptr> GetUsers(void) const;
        std::set<UserGroup::Ptr> GetUserGroups(void) const;
 
@@ -97,8 +97,6 @@ public:
 
        static String NotificationTypeToString(NotificationType type);
 
-       virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, String *result) const;
-
        static boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> OnNextNotificationChanged;
 
        static void RegisterApplyRuleHandler(void);
index 3ecc5cd5eb3a2fbf6f2effba8d87b0c4e09f2021..1d2c74e0d02f943363be3628bc3fbd4d8b92f7dd 100644 (file)
@@ -13,19 +13,19 @@ public:
 
 class Notification : DynamicObject < NotificationNameComposer
 {
-       [config, protected] String notification_command (NotificationCommandRaw);
-       [config] double notification_interval {
+       [config, protected] String command (CommandRaw);
+       [config] double interval {
                default {{{ return 1800; }}}
        };
-       [config] String notification_period (NotificationPeriodRaw);
+       [config] String period (PeriodRaw);
        [config] Dictionary::Ptr macros;
        [config, protected] Array::Ptr users (UsersRaw);
        [config, protected] Array::Ptr user_groups (UserGroupsRaw);
        [config] Dictionary::Ptr times;
-       [config] Array::Ptr notification_type_filter (NotificationTypeFilterRaw);
-       int notification_type_filter_real (NotificationTypeFilter);
-       [config] Array::Ptr notification_state_filter (NotificationStateFilterRaw);
-       int notification_state_filter_real (NotificationStateFilter);
+       [config] Array::Ptr types;
+       int type_filter_real (TypeFilter);
+       [config] Array::Ptr states;
+       int state_filter_real (StateFilter);
        [config, protected] String host_name;
        [config, protected] String service_name;
 
index 5e2f8497ca6bc2a53fc843a6c40b651845214ec0..a62c4eed368150a4dff911b524010083ab050847 100644 (file)
@@ -33,8 +33,8 @@ REGISTER_SCRIPTFUNCTION(ValidateUserFilters, &User::ValidateFilters);
 
 void User::OnConfigLoaded(void)
 {
-       SetNotificationTypeFilter(FilterArrayToInt(GetNotificationTypeFilterRaw(), ~0));
-       SetNotificationStateFilter(FilterArrayToInt(GetNotificationStateFilterRaw(), ~0));
+       SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
+       SetStateFilter(FilterArrayToInt(GetStates(), ~0));
 
        Array::Ptr groups = GetGroups();
 
@@ -68,9 +68,9 @@ void User::Stop(void)
        }
 }
 
-TimePeriod::Ptr User::GetNotificationPeriod(void) const
+TimePeriod::Ptr User::GetPeriod(void) const
 {
-       return TimePeriod::GetByName(GetNotificationPeriodRaw());
+       return TimePeriod::GetByName(GetPeriodRaw());
 }
 
 void User::ValidateFilters(const String& location, const Dictionary::Ptr& attrs)
index 4cff8709eaae222dd9b26611207c18dbda5ecb32..50417e4c708a86699e9daab1e6866829c119151d 100644 (file)
@@ -41,7 +41,7 @@ public:
        DECLARE_TYPENAME(User);
 
        /* Notifications */
-       TimePeriod::Ptr GetNotificationPeriod(void) const;
+       TimePeriod::Ptr GetPeriod(void) const;
 
        static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
 
index 74e9d74a33d438eb373d6e5d17e2178eef5cbfb7..2c25a763138740dbb15e856a9dcb849b3db0b8c4 100644 (file)
@@ -13,17 +13,16 @@ class User : DynamicObject
                                return m_DisplayName;
                }}}
        };
-       [config] Dictionary::Ptr macros;
        [config] Array::Ptr groups;
-       [config] String notification_period (NotificationPeriodRaw);
-       [config] Array::Ptr notification_type_filter (NotificationTypeFilterRaw);
-       int notification_type_filter_real (NotificationTypeFilter);
-       [config] Array::Ptr notification_state_filter (NotificationStateFilterRaw);
+       [config] String period (PeriodRaw);
+       [config] Array::Ptr types;
+       int type_filter_real (TypeFilter);
+       [config] Array::Ptr states;
+       int state_filter_real (StateFilter);
 
        [config] String email;
        [config] String pager;
 
-       int notification_state_filter_real (NotificationStateFilter);
        [state] bool enable_notifications;
        [state] double last_notification;
 };
index cccfb0059f1f7319c1f3b1d2df58ca801188e612..09967cf6c3695166cebcec3375c09fd908b612f9 100644 (file)
@@ -36,7 +36,7 @@ REGISTER_SCRIPTFUNCTION(PluginNotification, &PluginNotificationTask::ScriptFunc)
 void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
     const String& author, const String& comment)
 {
-       NotificationCommand::Ptr commandObj = notification->GetNotificationCommand();
+       NotificationCommand::Ptr commandObj = notification->GetCommand();
 
        NotificationType type = static_cast<NotificationType>(itype);