From bfe7d46a685bd9d9d21519eeff85f8c301058e32 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Tue, 7 Aug 2018 10:02:13 +0200 Subject: [PATCH 1/4] Only send acknowledgement notification if user received a problem notification refs #6047 --- lib/icinga/notification.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index a53c17e12..85ca54da7 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -409,6 +409,15 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe } } + /* on acknowledgement, check if user was notified before */ + if (type == NotificationAcknowledgement) { + if (!notifiedProblemUsers->Contains(userName)) { + Log(LogNotice, "Notification") + << "We did not notify user '" << userName << "' for a problem before. Not sending acknowledgement notification."; + continue; + } + } + Log(LogInformation, "Notification") << "Sending " << (reminder ? "reminder " : "") << "'" << NotificationTypeToStringInternal(type) << "' notification '" << GetName() << "' for user '" << userName << "'"; From 834e37d3e25726d4bc62da1ffc54051f4d9b3bfe Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Tue, 4 Sep 2018 13:11:28 +0200 Subject: [PATCH 2/4] Still notify on acknowledgement and recovery if user does not get problem notifications at all refs #6047 --- lib/icinga/notification.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index 85ca54da7..6da7f428f 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -402,7 +402,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe /* on recovery, check if user was notified before */ if (type == NotificationRecovery) { - if (!notifiedProblemUsers->Contains(userName)) { + if (!notifiedProblemUsers->Contains(userName) && CheckNotificationUserFilters(NotificationProblem, user, false, false)) { Log(LogNotice, "Notification") << "We did not notify user '" << userName << "' for a problem before. Not sending recovery notification."; continue; @@ -411,7 +411,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe /* on acknowledgement, check if user was notified before */ if (type == NotificationAcknowledgement) { - if (!notifiedProblemUsers->Contains(userName)) { + if (!notifiedProblemUsers->Contains(userName) && CheckNotificationUserFilters(NotificationProblem, user, false, false)) { Log(LogNotice, "Notification") << "We did not notify user '" << userName << "' for a problem before. Not sending acknowledgement notification."; continue; From af1f2e0c55eabc14c34b26a5195e7ae13fdf00cc Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 12 Sep 2018 17:04:11 +0200 Subject: [PATCH 3/4] Only check for Problem types in user filers for Recovery/Acknowledgement notifications refs #6047 --- lib/icinga/notification.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index 6da7f428f..9ac006e1e 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -402,18 +402,20 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe /* on recovery, check if user was notified before */ if (type == NotificationRecovery) { - if (!notifiedProblemUsers->Contains(userName) && CheckNotificationUserFilters(NotificationProblem, user, false, false)) { + if (!notifiedProblemUsers->Contains(userName) && (NotificationProblem & user->GetTypeFilter())) { Log(LogNotice, "Notification") - << "We did not notify user '" << userName << "' for a problem before. Not sending recovery notification."; + << "We did not notify user '" << userName + << "' (Problem types enabled) for a problem before. Not sending recovery notification."; continue; } } /* on acknowledgement, check if user was notified before */ if (type == NotificationAcknowledgement) { - if (!notifiedProblemUsers->Contains(userName) && CheckNotificationUserFilters(NotificationProblem, user, false, false)) { + if (!notifiedProblemUsers->Contains(userName) && (NotificationProblem & user->GetTypeFilter())) { Log(LogNotice, "Notification") - << "We did not notify user '" << userName << "' for a problem before. Not sending acknowledgement notification."; + << "We did not notify user '" << userName + << "' (Problem types enabled) for a problem before. Not sending acknowledgement notification."; continue; } } From 354e3c9093c154d3e2c704fd51149a3dd0b84c3c Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 12 Sep 2018 17:08:32 +0200 Subject: [PATCH 4/4] Update notification and upgrading docs for recovery/acknowledgement handling refs #6047 --- doc/03-monitoring-basics.md | 8 ++++++++ doc/16-upgrading-icinga-2.md | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/doc/03-monitoring-basics.md b/doc/03-monitoring-basics.md index 627423e62..a4775c69f 100644 --- a/doc/03-monitoring-basics.md +++ b/doc/03-monitoring-basics.md @@ -1553,6 +1553,14 @@ send notifications to all group members. > Only users who have been notified of a problem before (`Warning`, `Critical`, `Unknown` states for services, `Down` for hosts) will receive `Recovery` notifications. +Icinga 2 v2.10 allows you to configure `Acknowledgement` and/or `Recovery` +without a `Problem` notification. These notifications will be sent without +any problem notifications beforehand, and can be used for e.g. ticket systems. + +``` + types = [ Acknowledgement, Recovery ] +``` + ### Notifications: Users from Host/Service A common pattern is to store the users and user groups diff --git a/doc/16-upgrading-icinga-2.md b/doc/16-upgrading-icinga-2.md index 9c8d79a23..8bf58bc13 100644 --- a/doc/16-upgrading-icinga-2.md +++ b/doc/16-upgrading-icinga-2.md @@ -62,6 +62,31 @@ are counted as connected endpoints. A similar change is there for the performanc The attribute `child_options` was previously accepting 0,1,2 for specific child downtime settings. This behaviour stays intact, but the new proposed way are specific constants as values (`DowntimeNoChildren`, `DowntimeTriggeredChildren`, `DowntimeNonTriggeredChildren`). +### Notifications: Recovery and Acknowledgement + +When a user should be notified on `Problem` and `Acknowledgement`, v2.10 now checks during +the `Acknowledgement` notification event whether this user has been notified about a problem before. + +``` + types = [ Problem, Acknowledgement, Recovery ] +``` + +If **no** `Problem` notification was sent, and the types filter includes problems for this user, +the `Acknowledgement` notification is **not** sent. + +In contrast to that, the following configuration always sends `Acknowledgement` notifications. + +``` + types = [ Acknowledgement, Recovery ] +``` + +This change also restores the old behaviour for `Recovery` notifications. The above configuration +leaving out the `Problem` type can be used to only receive recovery notifications. If `Problem` +is added to the types again, Icinga 2 checks whether it has notified a user of a problem when +sending the recovery notification. + +More details can be found in [this PR](https://github.com/Icinga/icinga2/pull/6527). + ## Upgrading to v2.9 ### Deprecation and Removal Notes