return Empty;
/* same as service */
- TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+ TimePeriod::Ptr timeperiod = user->GetPeriod();
if (!timeperiod)
return Empty;
if (!user)
return Empty;
- TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+ TimePeriod::Ptr timeperiod = user->GetPeriod();
if (!timeperiod)
return Empty;
if (!user)
return Empty;
- TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+ TimePeriod::Ptr timeperiod = user->GetPeriod();
if (!timeperiod)
return Empty;
if (!user)
return Empty;
- TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
+ TimePeriod::Ptr timeperiod = user->GetPeriod();
if (!timeperiod)
return Empty;
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)))
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)
{
ObjectLock olock(notification);
- notification->SetNextNotification(Utility::GetTime() + notification->GetNotificationInterval());
+ notification->SetNextNotification(Utility::GetTime() + notification->GetInterval());
}
{
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
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.
apply Notification "mail" to Service {
import "generic-notification"
- notification_command = "mail-notification"
+ command = "mail-notification"
users = [ "icingaadmin" ]
assign where service.name == "mysql"
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.
> **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`.
apply Notification "mail" to Service {
import "generic-notification"
- notification_command = "mail-notification"
+ command = "mail-notification"
users = [ "icingaadmin" ]
assign where service.name == "ping4"
apply Notification "escalation-sms-2nd-level" to Service {
import "generic-notification"
- notification_command = "sms-notification"
+ command = "sms-notification"
users = [ "icinga-oncall-2nd-level" ]
times = {
apply Notification "escalation-sms-1st-level" to Service {
import "generic-notification"
- notification_command = "sms-notification"
+ command = "sms-notification"
users = [ "icinga-oncall-1st-level" ]
times = {
apply Notification "mail" to Service {
import "generic-notification"
- notification_command = "mail-notification"
+ command = "mail-notification"
users = [ "icingaadmin" ]
times.begin = 15m // delay first notification
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
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**
>
}
}
-Use the `notification_period` attribute to assign time periods to
+Use the `period` attribute to assign time periods to
`Notification` objects:
object Notification "mail" {
host_name = "localhost"
- notification_command = "mail-notification"
+ command = "mail-notification"
users = [ "icingaadmin" ]
- notification_period = "workhours"
+ period = "workhours"
}
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:
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:
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"
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
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
}
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.
* 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:
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, ...).
*/
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" {
}
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" {
groups = [ "icingaadmins" ]
email = "icinga@localhost"
- pager = "icingaadmin@localhost.localdomain"
}
object UserGroup "icingaadmins" {
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;
}
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)
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)
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)
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;
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;
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;
else
defaultFilter = StateFilterOK | StateFilterWarning;
- SetStateFilter(FilterArrayToInt(GetStateFilterRaw(), defaultFilter));
+ SetStateFilter(FilterArrayToInt(GetStates(), defaultFilter));
}
void Dependency::OnStateLoaded(void)
[config] String period (PeriodRaw);
- [config] Array::Ptr state_filter (StateFilterRaw);
+ [config] Array::Ptr states;
int state_filter_real (StateFilter);
[config] bool disable_checks;
%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",
void Notification::OnConfigLoaded(void)
{
- SetNotificationTypeFilter(FilterArrayToInt(GetNotificationTypeFilterRaw(), ~0));
- SetNotificationStateFilter(FilterArrayToInt(GetNotificationStateFilterRaw(), ~0));
+ SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
+ SetStateFilter(FilterArrayToInt(GetStates(), ~0));
GetCheckable()->AddNotification(GetSelf());
}
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
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
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");
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;
}
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;
}
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 '" +
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;
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;
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.");
}
}
-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;
-}
*
* @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);
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;
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);
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;
void User::OnConfigLoaded(void)
{
- SetNotificationTypeFilter(FilterArrayToInt(GetNotificationTypeFilterRaw(), ~0));
- SetNotificationStateFilter(FilterArrayToInt(GetNotificationStateFilterRaw(), ~0));
+ SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
+ SetStateFilter(FilterArrayToInt(GetStates(), ~0));
Array::Ptr groups = GetGroups();
}
}
-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)
DECLARE_TYPENAME(User);
/* Notifications */
- TimePeriod::Ptr GetNotificationPeriod(void) const;
+ TimePeriod::Ptr GetPeriod(void) const;
static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
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;
};
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);