mirror of https://github.com/Icinga/icinga2.git
parent
e24e128f65
commit
606834e190
|
@ -124,7 +124,7 @@ Value ContactsTable::HostNotificationPeriodAccessor(const Value& row)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* same as service */
|
/* same as service */
|
||||||
TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
|
TimePeriod::Ptr timeperiod = user->GetPeriod();
|
||||||
|
|
||||||
if (!timeperiod)
|
if (!timeperiod)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
@ -139,7 +139,7 @@ Value ContactsTable::ServiceNotificationPeriodAccessor(const Value& row)
|
||||||
if (!user)
|
if (!user)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
|
TimePeriod::Ptr timeperiod = user->GetPeriod();
|
||||||
|
|
||||||
if (!timeperiod)
|
if (!timeperiod)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
@ -174,7 +174,7 @@ Value ContactsTable::InHostNotificationPeriodAccessor(const Value& row)
|
||||||
if (!user)
|
if (!user)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
|
TimePeriod::Ptr timeperiod = user->GetPeriod();
|
||||||
|
|
||||||
if (!timeperiod)
|
if (!timeperiod)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
@ -189,7 +189,7 @@ Value ContactsTable::InServiceNotificationPeriodAccessor(const Value& row)
|
||||||
if (!user)
|
if (!user)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = user->GetNotificationPeriod();
|
TimePeriod::Ptr timeperiod = user->GetPeriod();
|
||||||
|
|
||||||
if (!timeperiod)
|
if (!timeperiod)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
|
@ -128,7 +128,7 @@ void StateHistTable::UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, in
|
||||||
bool in_notification_period = true;
|
bool in_notification_period = true;
|
||||||
String notification_period_name;
|
String notification_period_name;
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
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) {
|
||||||
if (notification_period->IsInside(static_cast<double>(time)))
|
if (notification_period->IsInside(static_cast<double>(time)))
|
||||||
|
|
|
@ -74,7 +74,7 @@ void NotificationComponent::NotificationTimerHandler(void)
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjects<Notification>()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, DynamicType::GetObjects<Notification>()) {
|
||||||
Checkable::Ptr checkable = notification->GetCheckable();
|
Checkable::Ptr checkable = notification->GetCheckable();
|
||||||
|
|
||||||
if (notification->GetNotificationInterval() <= 0 && notification->GetLastProblemNotification() < checkable->GetLastHardStateChange())
|
if (notification->GetInterval() <= 0 && notification->GetLastProblemNotification() < checkable->GetLastHardStateChange())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (notification->GetNextNotification() > now)
|
if (notification->GetNextNotification() > now)
|
||||||
|
@ -84,7 +84,7 @@ void NotificationComponent::NotificationTimerHandler(void)
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(notification);
|
ObjectLock olock(notification);
|
||||||
notification->SetNextNotification(Utility::GetTime() + notification->GetNotificationInterval());
|
notification->SetNextNotification(Utility::GetTime() + notification->GetInterval());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,17 +18,15 @@ The user `icingaadmin` in the example below will get notified only on `WARNING`
|
||||||
|
|
||||||
object User "icingaadmin" {
|
object User "icingaadmin" {
|
||||||
display_name = "Icinga 2 Admin"
|
display_name = "Icinga 2 Admin"
|
||||||
enable_notifications = 1
|
enable_notifications = true
|
||||||
notification_state_filter = [ OK, Warning, Critical ]
|
states = [ OK, Warning, Critical ]
|
||||||
notification_type_filter = [ Problem, Recovery ]
|
types = [ Problem, Recovery ]
|
||||||
vars.email = "icinga@localhost"
|
email = "icinga@localhost"
|
||||||
vars.pager = "+49123456789"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
If you don't set the `notification_state_filter` and `notification_type_filter`
|
If you don't set the `states` and `types`
|
||||||
configuration attributes for the `User` object, all states and types will be
|
configuration attributes for the `User` object, notifications for all states and types
|
||||||
notified.
|
will be sent.
|
||||||
|
|
||||||
You should choose which information you (and your notified users) are interested in
|
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
|
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
|
TODO
|
||||||
|
|
||||||
template Notification "generic-notification" {
|
template Notification "generic-notification" {
|
||||||
notification_interval = 15m
|
interval = 15m
|
||||||
|
|
||||||
notification_command = "mail-service-notification"
|
_command = "mail-service-notification"
|
||||||
|
|
||||||
notification_state_filter = [ Warning, Critical, Unknown ]
|
states = [ Warning, Critical, Unknown ]
|
||||||
notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
|
types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
|
||||||
FlappingEnd, DowntimeStart,DowntimeEnd, DowntimeRemoved ]
|
FlappingEnd, DowntimeStart,DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
notification_period = "24x7"
|
period = "24x7"
|
||||||
}
|
}
|
||||||
|
|
||||||
The time period `24x7` is shipped as example configuration with Icinga 2.
|
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 {
|
apply Notification "mail" to Service {
|
||||||
import "generic-notification"
|
import "generic-notification"
|
||||||
|
|
||||||
notification_command = "mail-notification"
|
command = "mail-notification"
|
||||||
users = [ "icingaadmin" ]
|
users = [ "icingaadmin" ]
|
||||||
|
|
||||||
assign where service.name == "mysql"
|
assign where service.name == "mysql"
|
||||||
|
@ -108,7 +106,7 @@ if not already solved.
|
||||||
You can define notification start and end times as additional configuration
|
You can define notification start and end times as additional configuration
|
||||||
attributes making the `Notification` object a so-called `notification escalation`.
|
attributes making the `Notification` object a so-called `notification escalation`.
|
||||||
Using templates you can share the basic notification attributes such as users or the
|
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
|
Using the example from above, you can define additional users being escalated for sms
|
||||||
notifications between start and end time.
|
notifications between start and end time.
|
||||||
|
@ -147,7 +145,7 @@ command) after `30m` until `1h`.
|
||||||
|
|
||||||
> **Note**
|
> **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 example. Lower that value in your escalations by using a secondary
|
||||||
> template or overriding the attribute directly in the `notifications` array
|
> template or overriding the attribute directly in the `notifications` array
|
||||||
> position for `escalation-sms-2nd-level`.
|
> 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 {
|
apply Notification "mail" to Service {
|
||||||
import "generic-notification"
|
import "generic-notification"
|
||||||
notification_command = "mail-notification"
|
command = "mail-notification"
|
||||||
users = [ "icingaadmin" ]
|
users = [ "icingaadmin" ]
|
||||||
|
|
||||||
assign where service.name == "ping4"
|
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 {
|
apply Notification "escalation-sms-2nd-level" to Service {
|
||||||
import "generic-notification"
|
import "generic-notification"
|
||||||
notification_command = "sms-notification"
|
command = "sms-notification"
|
||||||
users = [ "icinga-oncall-2nd-level" ]
|
users = [ "icinga-oncall-2nd-level" ]
|
||||||
|
|
||||||
times = {
|
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 {
|
apply Notification "escalation-sms-1st-level" to Service {
|
||||||
import "generic-notification"
|
import "generic-notification"
|
||||||
notification_command = "sms-notification"
|
command = "sms-notification"
|
||||||
users = [ "icinga-oncall-1st-level" ]
|
users = [ "icinga-oncall-1st-level" ]
|
||||||
|
|
||||||
times = {
|
times = {
|
||||||
|
@ -205,7 +203,7 @@ end time for this notification.
|
||||||
|
|
||||||
apply Notification "mail" to Service {
|
apply Notification "mail" to Service {
|
||||||
import "generic-notification"
|
import "generic-notification"
|
||||||
notification_command = "mail-notification"
|
command = "mail-notification"
|
||||||
users = [ "icingaadmin" ]
|
users = [ "icingaadmin" ]
|
||||||
|
|
||||||
times.begin = 15m // delay first notification
|
times.begin = 15m // delay first notification
|
||||||
|
@ -222,9 +220,9 @@ Available state and type filters for notifications are:
|
||||||
|
|
||||||
template Notification "generic-notification" {
|
template Notification "generic-notification" {
|
||||||
|
|
||||||
notification_state_filter = [ Warning, Critical, Unknown ]
|
states = [ Warning, Critical, Unknown ]
|
||||||
notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
|
types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart,
|
||||||
FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
}
|
}
|
||||||
|
|
||||||
If you are familiar with Icinga 1.x `notification_options` please note that they have been split
|
If you are familiar with Icinga 1.x `notification_options` please note that they have been split
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
Time Periods define time ranges in Icinga where event actions are
|
Time Periods define time ranges in Icinga where event actions are
|
||||||
triggered, for example if a service check is executed or not within
|
triggered, for example if a service check is executed or not within
|
||||||
the `check_period` attribute. Or a notification should be sent to
|
the `check_period` attribute. Or a notification should be sent to
|
||||||
users or not, filtered by the `notification_period` configuration
|
users or not, filtered by the `period` and `notification_period`
|
||||||
attribute for `Notification` and `User` objects.
|
configuration attributes for `Notification` and `User` objects.
|
||||||
|
|
||||||
> **Note**
|
> **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:
|
`Notification` objects:
|
||||||
|
|
||||||
object Notification "mail" {
|
object Notification "mail" {
|
||||||
|
@ -71,7 +71,7 @@ Use the `notification_period` attribute to assign time periods to
|
||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
|
|
||||||
notification_command = "mail-notification"
|
command = "mail-notification"
|
||||||
users = [ "icingaadmin" ]
|
users = [ "icingaadmin" ]
|
||||||
notification_period = "workhours"
|
period = "workhours"
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,11 +131,11 @@ Example:
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
service_name = "ping4"
|
service_name = "ping4"
|
||||||
|
|
||||||
notification_command = "mail-notification"
|
command = "mail-notification"
|
||||||
|
|
||||||
users = [ "user1", "user2" ]
|
users = [ "user1", "user2" ]
|
||||||
|
|
||||||
notification_type_filter = [ Problem, Recovery ]
|
types = [ Problem, Recovery ]
|
||||||
}
|
}
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
@ -148,11 +148,11 @@ Attributes:
|
||||||
users | **Optional.** A list of user names who should be notified.
|
users | **Optional.** A list of user names who should be notified.
|
||||||
user_groups | **Optional.** A list of user group 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.
|
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.
|
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.
|
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.
|
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.
|
types | **Optional.** A list of type 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.
|
states | **Optional.** A list of type filters when this notification should be triggered. By default everything is matched.
|
||||||
|
|
||||||
Available notification state filters:
|
Available notification state filters:
|
||||||
|
|
||||||
|
@ -235,11 +235,10 @@ Example:
|
||||||
display_name = "Icinga 2 Admin"
|
display_name = "Icinga 2 Admin"
|
||||||
groups = [ "icingaadmins" ]
|
groups = [ "icingaadmins" ]
|
||||||
|
|
||||||
enable_notifications = 1
|
notificcation_period = "24x7"
|
||||||
notification_period = "24x7"
|
|
||||||
|
|
||||||
notification_state_filter = [ OK, Warning, Critical, Unknown ]
|
states = [ OK, Warning, Critical, Unknown ]
|
||||||
notification_type_filter = [ Problem, Recovery ]
|
types = [ Problem, Recovery ]
|
||||||
|
|
||||||
vars = {
|
vars = {
|
||||||
name = "Icinga 2 Admin"
|
name = "Icinga 2 Admin"
|
||||||
|
@ -281,9 +280,9 @@ Attributes:
|
||||||
vars |**Optional.** A dictionary containing custom attributes that are specific to this user.
|
vars |**Optional.** A dictionary containing custom attributes that are specific to this user.
|
||||||
groups |**Optional.** An array of group names.
|
groups |**Optional.** An array of group names.
|
||||||
enable_notifications|**Optional.** Whether notifications are enabled for this user.
|
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.
|
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.
|
types |**Optional.** A set of type 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.
|
states |**Optional.** A set of state filters when this notification should be triggered. By default everything is matched.
|
||||||
|
|
||||||
### <a id="objecttype-usergroup"></a> UserGroup
|
### <a id="objecttype-usergroup"></a> UserGroup
|
||||||
|
|
||||||
|
@ -523,8 +522,8 @@ Example:
|
||||||
|
|
||||||
service_perfdata_path = "/var/spool/icinga2/perfdata/service-perfdata"
|
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$"
|
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.description$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.checkcommand$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.statetype$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.statetype$"
|
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
|
rotation_interval = 15s
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ By default all services remain in a non-volatile state. When a problem
|
||||||
occurs, the `SOFT` state applies and once `max_check_attempts` attribute
|
occurs, the `SOFT` state applies and once `max_check_attempts` attribute
|
||||||
is reached with the check counter, a `HARD` state transition happens.
|
is reached with the check counter, a `HARD` state transition happens.
|
||||||
Notifications are only triggered by `HARD` state changes and are then
|
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`
|
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
|
state type if the service stays in a `NOT-OK` state. That way each
|
||||||
|
|
|
@ -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 X, set SMS and Mail attributes, used for authorization
|
||||||
* Create user Y, 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
|
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
|
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
|
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
|
assign notification C-Mail to service C
|
||||||
|
|
||||||
Previously in Icinga 1.x it looked like this:
|
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_options w,u,c,r,f,s
|
||||||
|
|
||||||
notification_state_filter = [ Warning, Unknown, Critical ]
|
states = [ Warning, Unknown, Critical ]
|
||||||
notification_type_filter = [ Problem, Recovery, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
filters = [ Problem, Recovery, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
Icinga 2 adds more fine-grained type filters for acknowledgements, downtime
|
Icinga 2 adds more fine-grained type filters for acknowledgements, downtime
|
||||||
and flapping type (start, end, ...).
|
and flapping type (start, end, ...).
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template Notification "mail-host-notification" {
|
template Notification "mail-host-notification" {
|
||||||
notification_command = "mail-host-notification"
|
command = "mail-host-notification"
|
||||||
|
|
||||||
notification_state_filter = [ Up, Down ]
|
states = [ Up, Down ]
|
||||||
notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom,
|
types = [ Problem, Acknowledgement, Recovery, Custom,
|
||||||
FlappingStart, FlappingEnd,
|
FlappingStart, FlappingEnd,
|
||||||
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
notification_period = "24x7"
|
period = "24x7"
|
||||||
}
|
}
|
||||||
|
|
||||||
object NotificationCommand "mail-host-notification" {
|
object NotificationCommand "mail-host-notification" {
|
||||||
|
@ -33,14 +33,14 @@ object NotificationCommand "mail-host-notification" {
|
||||||
}
|
}
|
||||||
|
|
||||||
template Notification "mail-service-notification" {
|
template Notification "mail-service-notification" {
|
||||||
notification_command = "mail-service-notification"
|
command = "mail-service-notification"
|
||||||
|
|
||||||
notification_state_filter = [ OK, Warning, Critical, Unknown ]
|
states = [ OK, Warning, Critical, Unknown ]
|
||||||
notification_type_filter = [ Problem, Acknowledgement, Recovery, Custom,
|
types = [ Problem, Acknowledgement, Recovery, Custom,
|
||||||
FlappingStart, FlappingEnd,
|
FlappingStart, FlappingEnd,
|
||||||
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
notification_period = "24x7"
|
period = "24x7"
|
||||||
}
|
}
|
||||||
|
|
||||||
object NotificationCommand "mail-service-notification" {
|
object NotificationCommand "mail-service-notification" {
|
||||||
|
|
|
@ -10,7 +10,6 @@ object User "icingaadmin" {
|
||||||
groups = [ "icingaadmins" ]
|
groups = [ "icingaadmins" ]
|
||||||
|
|
||||||
email = "icinga@localhost"
|
email = "icinga@localhost"
|
||||||
pager = "icingaadmin@localhost.localdomain"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object UserGroup "icingaadmins" {
|
object UserGroup "icingaadmins" {
|
||||||
|
|
|
@ -49,22 +49,22 @@ Dictionary::Ptr UserDbObject::GetConfigFields(void) const
|
||||||
fields->Set("pager_address", vars->Get("pager"));
|
fields->Set("pager_address", vars->Get("pager"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fields->Set("host_timeperiod_object_id", user->GetNotificationPeriod());
|
fields->Set("host_timeperiod_object_id", user->GetPeriod());
|
||||||
fields->Set("service_timeperiod_object_id", user->GetNotificationPeriod());
|
fields->Set("service_timeperiod_object_id", user->GetPeriod());
|
||||||
fields->Set("host_notifications_enabled", user->GetEnableNotifications());
|
fields->Set("host_notifications_enabled", user->GetEnableNotifications());
|
||||||
fields->Set("service_notifications_enabled", user->GetEnableNotifications());
|
fields->Set("service_notifications_enabled", user->GetEnableNotifications());
|
||||||
fields->Set("can_submit_commands", 1);
|
fields->Set("can_submit_commands", 1);
|
||||||
fields->Set("notify_service_recovery", user->GetNotificationStateFilter() & NotificationRecovery);
|
fields->Set("notify_service_recovery", (user->GetStateFilter() & NotificationRecovery) != 0);
|
||||||
fields->Set("notify_service_warning", user->GetNotificationStateFilter() & NotificationProblem);
|
fields->Set("notify_service_warning", (user->GetStateFilter() & NotificationProblem) != 0);
|
||||||
fields->Set("notify_service_unknown", user->GetNotificationStateFilter() & NotificationProblem);
|
fields->Set("notify_service_unknown", (user->GetStateFilter() & NotificationProblem) != 0);
|
||||||
fields->Set("notify_service_critical", user->GetNotificationStateFilter() & NotificationProblem);
|
fields->Set("notify_service_critical", (user->GetStateFilter() & NotificationProblem) != 0);
|
||||||
fields->Set("notify_service_flapping", user->GetNotificationStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd));
|
fields->Set("notify_service_flapping", (user->GetStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd)) != 0);
|
||||||
fields->Set("notify_service_downtime", user->GetNotificationStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved));
|
fields->Set("notify_service_downtime", (user->GetStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0);
|
||||||
fields->Set("notify_host_recovery", user->GetNotificationStateFilter() & NotificationRecovery);
|
fields->Set("notify_host_recovery", (user->GetStateFilter() & NotificationRecovery) != 0);
|
||||||
fields->Set("notify_host_down", user->GetNotificationStateFilter() & NotificationProblem);
|
fields->Set("notify_host_down", (user->GetStateFilter() & NotificationProblem) != 0);
|
||||||
fields->Set("notify_host_unreachable", user->GetNotificationStateFilter() & NotificationProblem);
|
fields->Set("notify_host_unreachable", (user->GetStateFilter() & NotificationProblem) != 0);
|
||||||
fields->Set("notify_host_flapping", user->GetNotificationStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd));
|
fields->Set("notify_host_flapping", (user->GetStateFilter() & (NotificationFlappingStart | NotificationFlappingEnd)) != 0);
|
||||||
fields->Set("notify_host_downtime", user->GetNotificationStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved));
|
fields->Set("notify_host_downtime", (user->GetStateFilter() & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0);
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
||||||
ObjectLock olock(notification);
|
ObjectLock olock(notification);
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = notification->GetNotificationPeriod();
|
TimePeriod::Ptr timeperiod = notification->GetPeriod();
|
||||||
|
|
||||||
/* first notification wins */
|
/* first notification wins */
|
||||||
if (timeperiod)
|
if (timeperiod)
|
||||||
|
@ -487,8 +487,8 @@ double CompatUtility::GetCheckableNotificationNotificationInterval(const Checkab
|
||||||
double notification_interval = -1;
|
double notification_interval = -1;
|
||||||
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
||||||
if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
|
if (notification_interval == -1 || notification->GetInterval() < notification_interval)
|
||||||
notification_interval = notification->GetNotificationInterval();
|
notification_interval = notification->GetInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification_interval == -1)
|
if (notification_interval == -1)
|
||||||
|
@ -505,8 +505,8 @@ String CompatUtility::GetCheckableNotificationNotificationPeriod(const Checkable
|
||||||
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
||||||
|
|
||||||
if (notification->GetNotificationPeriod())
|
if (notification->GetPeriod())
|
||||||
notification_period = notification->GetNotificationPeriod();
|
notification_period = notification->GetPeriod();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!notification_period)
|
if (!notification_period)
|
||||||
|
@ -523,11 +523,8 @@ String CompatUtility::GetCheckableNotificationNotificationOptions(const Checkabl
|
||||||
unsigned long notification_state_filter = 0;
|
unsigned long notification_state_filter = 0;
|
||||||
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
||||||
if (notification->GetNotificationTypeFilter())
|
notification_type_filter = notification->GetTypeFilter();
|
||||||
notification_type_filter = notification->GetNotificationTypeFilter();
|
notification_state_filter = notification->GetStateFilter();
|
||||||
|
|
||||||
if (notification->GetNotificationStateFilter())
|
|
||||||
notification_state_filter = notification->GetNotificationStateFilter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<String> notification_options;
|
std::vector<String> notification_options;
|
||||||
|
@ -569,8 +566,7 @@ int CompatUtility::GetCheckableNotificationTypeFilter(const Checkable::Ptr& chec
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
||||||
ObjectLock olock(notification);
|
ObjectLock olock(notification);
|
||||||
|
|
||||||
if (notification->GetNotificationTypeFilter())
|
notification_type_filter = notification->GetTypeFilter();
|
||||||
notification_type_filter = notification->GetNotificationTypeFilter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return notification_type_filter;
|
return notification_type_filter;
|
||||||
|
@ -585,8 +581,7 @@ int CompatUtility::GetCheckableNotificationStateFilter(const Checkable::Ptr& che
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
BOOST_FOREACH(const Notification::Ptr& notification, checkable->GetNotifications()) {
|
||||||
ObjectLock olock(notification);
|
ObjectLock olock(notification);
|
||||||
|
|
||||||
if (notification->GetNotificationStateFilter())
|
notification_state_filter = notification->GetStateFilter();
|
||||||
notification_state_filter = notification->GetNotificationStateFilter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return notification_state_filter;
|
return notification_state_filter;
|
||||||
|
|
|
@ -55,7 +55,7 @@ void Dependency::OnConfigLoaded(void)
|
||||||
else
|
else
|
||||||
defaultFilter = StateFilterOK | StateFilterWarning;
|
defaultFilter = StateFilterOK | StateFilterWarning;
|
||||||
|
|
||||||
SetStateFilter(FilterArrayToInt(GetStateFilterRaw(), defaultFilter));
|
SetStateFilter(FilterArrayToInt(GetStates(), defaultFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dependency::OnStateLoaded(void)
|
void Dependency::OnStateLoaded(void)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Dependency : DynamicObject < DependencyNameComposer
|
||||||
|
|
||||||
[config] String period (PeriodRaw);
|
[config] String period (PeriodRaw);
|
||||||
|
|
||||||
[config] Array::Ptr state_filter (StateFilterRaw);
|
[config] Array::Ptr states;
|
||||||
int state_filter_real (StateFilter);
|
int state_filter_real (StateFilter);
|
||||||
|
|
||||||
[config] bool disable_checks;
|
[config] bool disable_checks;
|
||||||
|
|
|
@ -110,16 +110,16 @@
|
||||||
%attribute %number "end",
|
%attribute %number "end",
|
||||||
},
|
},
|
||||||
|
|
||||||
%require "notification_command",
|
%require "command",
|
||||||
%attribute %name(NotificationCommand) "notification_command",
|
%attribute %name(NotificationCommand) "command",
|
||||||
|
|
||||||
%attribute %number "notification_interval",
|
%attribute %number "interval",
|
||||||
%attribute %name(TimePeriod) "notification_period",
|
%attribute %name(TimePeriod) "period",
|
||||||
|
|
||||||
%attribute %array "notification_type_filter" {
|
%attribute %array "types" {
|
||||||
%attribute %number "*"
|
%attribute %number "*"
|
||||||
},
|
},
|
||||||
%attribute %array "notification_state_filter" {
|
%attribute %array "states" {
|
||||||
%attribute %number "*"
|
%attribute %number "*"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -136,13 +136,13 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
%attribute %number "enable_notifications",
|
%attribute %number "enable_notifications",
|
||||||
%attribute %array "notification_type_filter" {
|
%attribute %array "types" {
|
||||||
%attribute %number "*"
|
%attribute %number "*"
|
||||||
},
|
},
|
||||||
%attribute %array "notification_state_filter" {
|
%attribute %array "states" {
|
||||||
%attribute %number "*"
|
%attribute %number "*"
|
||||||
},
|
},
|
||||||
%attribute %name(TimePeriod) "notification_period",
|
%attribute %name(TimePeriod) "period",
|
||||||
|
|
||||||
%attribute %string "email",
|
%attribute %string "email",
|
||||||
%attribute %string "pager",
|
%attribute %string "pager",
|
||||||
|
|
|
@ -78,8 +78,8 @@ void Notification::StaticInitialize(void)
|
||||||
|
|
||||||
void Notification::OnConfigLoaded(void)
|
void Notification::OnConfigLoaded(void)
|
||||||
{
|
{
|
||||||
SetNotificationTypeFilter(FilterArrayToInt(GetNotificationTypeFilterRaw(), ~0));
|
SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
|
||||||
SetNotificationStateFilter(FilterArrayToInt(GetNotificationStateFilterRaw(), ~0));
|
SetStateFilter(FilterArrayToInt(GetStates(), ~0));
|
||||||
|
|
||||||
GetCheckable()->AddNotification(GetSelf());
|
GetCheckable()->AddNotification(GetSelf());
|
||||||
}
|
}
|
||||||
|
@ -108,9 +108,9 @@ Checkable::Ptr Notification::GetCheckable(void) const
|
||||||
return host->GetServiceByShortName(GetServiceName());
|
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
|
std::set<User::Ptr> Notification::GetUsers(void) const
|
||||||
|
@ -157,9 +157,9 @@ std::set<UserGroup::Ptr> Notification::GetUserGroups(void) const
|
||||||
return result;
|
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
|
double Notification::GetNextNotification(void) const
|
||||||
|
@ -221,7 +221,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
|
||||||
Checkable::Ptr checkable = GetCheckable();
|
Checkable::Ptr checkable = GetCheckable();
|
||||||
|
|
||||||
if (!force) {
|
if (!force) {
|
||||||
TimePeriod::Ptr tp = GetNotificationPeriod();
|
TimePeriod::Ptr tp = GetPeriod();
|
||||||
|
|
||||||
if (tp && !tp->IsInside(Utility::GetTime())) {
|
if (tp && !tp->IsInside(Utility::GetTime())) {
|
||||||
Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': not in timeperiod");
|
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;
|
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");
|
Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': type filter does not match");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
|
||||||
else
|
else
|
||||||
fstate = HostStateToFilter(host->GetState());
|
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");
|
Log(LogInformation, "icinga", "Not sending notifications for notification object '" + GetName() + "': state filter does not match");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ bool Notification::CheckNotificationUserFilters(NotificationType type, const Use
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
if (!force) {
|
if (!force) {
|
||||||
TimePeriod::Ptr tp = user->GetNotificationPeriod();
|
TimePeriod::Ptr tp = user->GetPeriod();
|
||||||
|
|
||||||
if (tp && !tp->IsInside(Utility::GetTime())) {
|
if (tp && !tp->IsInside(Utility::GetTime())) {
|
||||||
Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
|
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;
|
unsigned long ftype = 1 << type;
|
||||||
|
|
||||||
if (!(ftype & user->GetNotificationTypeFilter())) {
|
if (!(ftype & user->GetTypeFilter())) {
|
||||||
Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
|
Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
|
||||||
GetName() + " and user '" + user->GetName() + "': type filter does not match");
|
GetName() + " and user '" + user->GetName() + "': type filter does not match");
|
||||||
return false;
|
return false;
|
||||||
|
@ -340,7 +340,7 @@ bool Notification::CheckNotificationUserFilters(NotificationType type, const Use
|
||||||
else
|
else
|
||||||
fstate = HostStateToFilter(host->GetState());
|
fstate = HostStateToFilter(host->GetState());
|
||||||
|
|
||||||
if (!(fstate & user->GetNotificationStateFilter())) {
|
if (!(fstate & user->GetStateFilter())) {
|
||||||
Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
|
Log(LogInformation, "icinga", "Not sending notifications for notification object '" +
|
||||||
GetName() + " and user '" + user->GetName() + "': state filter does not match");
|
GetName() + " and user '" + user->GetName() + "': state filter does not match");
|
||||||
return false;
|
return false;
|
||||||
|
@ -355,7 +355,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NotificationCommand::Ptr command = GetNotificationCommand();
|
NotificationCommand::Ptr command = GetCommand();
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
Log(LogDebug, "icinga", "No notification_command found for notification '" + GetName() + "'. Skipping execution.");
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Checkable;
|
||||||
*
|
*
|
||||||
* @ingroup icinga
|
* @ingroup icinga
|
||||||
*/
|
*/
|
||||||
class I2_ICINGA_API Notification : public ObjectImpl<Notification>, public MacroResolver
|
class I2_ICINGA_API Notification : public ObjectImpl<Notification>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Notification);
|
DECLARE_PTR_TYPEDEFS(Notification);
|
||||||
|
@ -80,8 +80,8 @@ public:
|
||||||
static void StaticInitialize(void);
|
static void StaticInitialize(void);
|
||||||
|
|
||||||
shared_ptr<Checkable> GetCheckable(void) const;
|
shared_ptr<Checkable> GetCheckable(void) const;
|
||||||
shared_ptr<NotificationCommand> GetNotificationCommand(void) const;
|
shared_ptr<NotificationCommand> GetCommand(void) const;
|
||||||
TimePeriod::Ptr GetNotificationPeriod(void) const;
|
TimePeriod::Ptr GetPeriod(void) const;
|
||||||
std::set<User::Ptr> GetUsers(void) const;
|
std::set<User::Ptr> GetUsers(void) const;
|
||||||
std::set<UserGroup::Ptr> GetUserGroups(void) const;
|
std::set<UserGroup::Ptr> GetUserGroups(void) const;
|
||||||
|
|
||||||
|
@ -97,8 +97,6 @@ public:
|
||||||
|
|
||||||
static String NotificationTypeToString(NotificationType type);
|
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 boost::signals2::signal<void (const Notification::Ptr&, double, const String&)> OnNextNotificationChanged;
|
||||||
|
|
||||||
static void RegisterApplyRuleHandler(void);
|
static void RegisterApplyRuleHandler(void);
|
||||||
|
|
|
@ -13,19 +13,19 @@ public:
|
||||||
|
|
||||||
class Notification : DynamicObject < NotificationNameComposer
|
class Notification : DynamicObject < NotificationNameComposer
|
||||||
{
|
{
|
||||||
[config, protected] String notification_command (NotificationCommandRaw);
|
[config, protected] String command (CommandRaw);
|
||||||
[config] double notification_interval {
|
[config] double interval {
|
||||||
default {{{ return 1800; }}}
|
default {{{ return 1800; }}}
|
||||||
};
|
};
|
||||||
[config] String notification_period (NotificationPeriodRaw);
|
[config] String period (PeriodRaw);
|
||||||
[config] Dictionary::Ptr macros;
|
[config] Dictionary::Ptr macros;
|
||||||
[config, protected] Array::Ptr users (UsersRaw);
|
[config, protected] Array::Ptr users (UsersRaw);
|
||||||
[config, protected] Array::Ptr user_groups (UserGroupsRaw);
|
[config, protected] Array::Ptr user_groups (UserGroupsRaw);
|
||||||
[config] Dictionary::Ptr times;
|
[config] Dictionary::Ptr times;
|
||||||
[config] Array::Ptr notification_type_filter (NotificationTypeFilterRaw);
|
[config] Array::Ptr types;
|
||||||
int notification_type_filter_real (NotificationTypeFilter);
|
int type_filter_real (TypeFilter);
|
||||||
[config] Array::Ptr notification_state_filter (NotificationStateFilterRaw);
|
[config] Array::Ptr states;
|
||||||
int notification_state_filter_real (NotificationStateFilter);
|
int state_filter_real (StateFilter);
|
||||||
[config, protected] String host_name;
|
[config, protected] String host_name;
|
||||||
[config, protected] String service_name;
|
[config, protected] String service_name;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ REGISTER_SCRIPTFUNCTION(ValidateUserFilters, &User::ValidateFilters);
|
||||||
|
|
||||||
void User::OnConfigLoaded(void)
|
void User::OnConfigLoaded(void)
|
||||||
{
|
{
|
||||||
SetNotificationTypeFilter(FilterArrayToInt(GetNotificationTypeFilterRaw(), ~0));
|
SetTypeFilter(FilterArrayToInt(GetTypes(), ~0));
|
||||||
SetNotificationStateFilter(FilterArrayToInt(GetNotificationStateFilterRaw(), ~0));
|
SetStateFilter(FilterArrayToInt(GetStates(), ~0));
|
||||||
|
|
||||||
Array::Ptr groups = GetGroups();
|
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)
|
void User::ValidateFilters(const String& location, const Dictionary::Ptr& attrs)
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
DECLARE_TYPENAME(User);
|
DECLARE_TYPENAME(User);
|
||||||
|
|
||||||
/* Notifications */
|
/* Notifications */
|
||||||
TimePeriod::Ptr GetNotificationPeriod(void) const;
|
TimePeriod::Ptr GetPeriod(void) const;
|
||||||
|
|
||||||
static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
|
static void ValidateFilters(const String& location, const Dictionary::Ptr& attrs);
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,16 @@ class User : DynamicObject
|
||||||
return m_DisplayName;
|
return m_DisplayName;
|
||||||
}}}
|
}}}
|
||||||
};
|
};
|
||||||
[config] Dictionary::Ptr macros;
|
|
||||||
[config] Array::Ptr groups;
|
[config] Array::Ptr groups;
|
||||||
[config] String notification_period (NotificationPeriodRaw);
|
[config] String period (PeriodRaw);
|
||||||
[config] Array::Ptr notification_type_filter (NotificationTypeFilterRaw);
|
[config] Array::Ptr types;
|
||||||
int notification_type_filter_real (NotificationTypeFilter);
|
int type_filter_real (TypeFilter);
|
||||||
[config] Array::Ptr notification_state_filter (NotificationStateFilterRaw);
|
[config] Array::Ptr states;
|
||||||
|
int state_filter_real (StateFilter);
|
||||||
|
|
||||||
[config] String email;
|
[config] String email;
|
||||||
[config] String pager;
|
[config] String pager;
|
||||||
|
|
||||||
int notification_state_filter_real (NotificationStateFilter);
|
|
||||||
[state] bool enable_notifications;
|
[state] bool enable_notifications;
|
||||||
[state] double last_notification;
|
[state] double last_notification;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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,
|
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, const User::Ptr& user, const CheckResult::Ptr& cr, int itype,
|
||||||
const String& author, const String& comment)
|
const String& author, const String& comment)
|
||||||
{
|
{
|
||||||
NotificationCommand::Ptr commandObj = notification->GetNotificationCommand();
|
NotificationCommand::Ptr commandObj = notification->GetCommand();
|
||||||
|
|
||||||
NotificationType type = static_cast<NotificationType>(itype);
|
NotificationType type = static_cast<NotificationType>(itype);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue