[icinga-checkins] icinga.org: icinga2/master: Fix: Timeperiods: legacy-timeperiod parsed empty, results in skipped checks

git at icinga.org git at icinga.org
Mon Jun 24 15:01:35 CEST 2013


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

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Jun 24 15:01:23 2013 +0200

Fix: Timeperiods: legacy-timeperiod parsed empty, results in skipped checks

Fixes #4336

---

 lib/icinga/legacytimeperiod.cpp |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/icinga/legacytimeperiod.cpp b/lib/icinga/legacytimeperiod.cpp
index b9bcdae..67d4d01 100644
--- a/lib/icinga/legacytimeperiod.cpp
+++ b/lib/icinga/legacytimeperiod.cpp
@@ -46,7 +46,7 @@ bool LegacyTimePeriod::IsInTimeRange(tm *begin, tm *end, int stride, tm *referen
 
 	int daynumber = (tsref - tsbegin) / (24 * 60 * 60);
 
-	if (daynumber % stride == 0)
+	if (stride > 1 && daynumber % stride == 0)
 		return false;
 
 	return true;
@@ -324,6 +324,8 @@ bool LegacyTimePeriod::IsInDayDefinition(const String& daydef, tm *reference)
 
 	ParseTimeRange(daydef, &begin, &end, &stride, reference);
 
+	Log(LogDebug, "icinga", "ParseTimeRange: '" + daydef + "' => " + Convert::ToString(mktime(&begin)) + " -> " + Convert::ToString(mktime(&end)) + ", stride: " + Convert::ToString(stride));
+
 	return IsInTimeRange(&begin, &end, stride, reference);
 }
 
@@ -389,6 +391,8 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
 			time_t refts = begin + i * 24 * 60 * 60;
 			tm reference;
 
+			Log(LogDebug, "icinga", "Checking reference time " + Convert::ToString(refts));
+
 #ifdef _MSC_VER
 			tm *temp = localtime(&refts);
 
@@ -411,8 +415,12 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
 			String key;
 			Value value;
 			BOOST_FOREACH(boost::tie(key, value), ranges) {
-				if (!IsInDayDefinition(key, &reference))
+				if (!IsInDayDefinition(key, &reference)) {
+					Log(LogDebug, "icinga", "Not in day definition '" + key + "'.");
 					continue;
+				}
+
+				Log(LogDebug, "icinga", "In day definition '" + key + "'.");
 
 				ProcessTimeRanges(value, &reference, segments);
 			}





More information about the icinga-checkins mailing list