[icinga-checkins] icinga.org: icinga2/master: Fix that notifications with empty times.{begin , end} are not sent

git at icinga.org git at icinga.org
Thu Aug 4 17:28:08 CEST 2016


Module: icinga2
Branch: master
Commit: 43a177fb16751117420cf3addb43dada49ad3ac8
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=43a177fb16751117420cf3addb43dada49ad3ac8

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu Aug  4 17:27:35 2016 +0200

Fix that notifications with empty times.{begin,end} are not sent

fixes #10363

---

 lib/icinga/notification.cpp |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp
index 885c6fd..ca2db2b 100644
--- a/lib/icinga/notification.cpp
+++ b/lib/icinga/notification.cpp
@@ -282,24 +282,29 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
 		double now = Utility::GetTime();
 		Dictionary::Ptr times = GetTimes();
 
-		if (type == NotificationProblem) {
-			if (times && times->Contains("begin") && now < checkable->GetLastHardStateChange() + times->Get("begin")) {
+		if (times && type == NotificationProblem) {
+			Value timesBegin = times->Get("begin");
+			Value timesEnd = times->Get("end");
+
+			if (timesBegin != Empty && timesBegin >= 0 && now < checkable->GetLastHardStateChange() + timesBegin) {
 				Log(LogNotice, "Notification")
-				    << "Not sending notifications for notification object '" << GetName() << "': before escalation range";
+				    << "Not sending notifications for notification object '" << GetName()
+				    << "': before specified begin time (" << Utility::FormatDuration(timesBegin) << ")";
 
 				/* we need to adjust the next notification time
 				 * to now + begin delaying the first notification
 				 */
-				double nextProposedNotification = now + times->Get("begin") + 1.0;
+				double nextProposedNotification = now + timesBegin + 1.0;
 				if (GetNextNotification() > nextProposedNotification)
 					SetNextNotification(nextProposedNotification);
 
 				return;
 			}
 
-			if (times && times->Contains("end") && now > checkable->GetLastHardStateChange() + times->Get("end")) {
+			if (timesEnd != Empty && timesEnd >= 0 && now > checkable->GetLastHardStateChange() + timesEnd) {
 				Log(LogNotice, "Notification")
-				    << "Not sending notifications for notification object '" << GetName() << "': after escalation range";
+				    << "Not sending notifications for notification object '" << GetName()
+				    << "': after specified end time (" << Utility::FormatDuration(timesEnd) << ")";
 				return;
 			}
 		}



More information about the icinga-checkins mailing list