Rename the notification attributes.

Fixes #5906
This commit is contained in:
Gunnar Beutner 2014-04-09 10:25:23 +02:00
parent e24e128f65
commit 606834e190
22 changed files with 137 additions and 164 deletions

View 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;

View 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)))

View 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());
}
{

View 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

View 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"
}

View 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
}

View 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.
service is acknowledged or in a scheduled downtime.

View 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, ...).

View 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" {

View File

@ -10,7 +10,6 @@ object User "icingaadmin" {
groups = [ "icingaadmins" ]
email = "icinga@localhost"
pager = "icingaadmin@localhost.localdomain"
}
object UserGroup "icingaadmins" {

View 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;
}

View 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;

View 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)

View 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;

View File

@ -110,16 +110,16 @@
%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 "*"
},
@ -136,13 +136,13 @@
},
%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",

View 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;
}

View 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);

View 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;

View 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)

View 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);

View 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;
};

View 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);