Module: check_mk
Branch: master
Commit: 907779d962448107deccb1e8f7aee09ebd5a5fc8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=907779d9624481…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Mar 22 15:07:38 2016 +0100
3107 FIX heartbeat_crm: fixed incorrect timezone handling
The service "Heartbeat CRM General" calculated the status output age
incorrectly, using comparing a
time in UTC to one in the local timezone of the server.
The fix required the addition of a conversion function to the check api.
---
.werks/3107 | 12 ++++++++++++
ChangeLog | 1 +
checks/heartbeat_crm | 2 +-
modules/check_mk_base.py | 5 +++++
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/.werks/3107 b/.werks/3107
new file mode 100644
index 0000000..a0e50b3
--- /dev/null
+++ b/.werks/3107
@@ -0,0 +1,12 @@
+Title: heartbeat_crm: fixed incorrect timezone handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1458655464
+
+The service "Heartbeat CRM General" calculated the status output age
incorrectly, using comparing a
+time in UTC to one in the local timezone of the server.
+The fix required the addition of a conversion function to the check api.
diff --git a/ChangeLog b/ChangeLog
index 6939861..6fb8537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -101,6 +101,7 @@
* 3333 FIX: Predictive levels: Improved error handling in case no RRDs have been
created yet
* 3317 FIX: lnx_bonding: handle bogus output of 1.2.6 agents where >/dev/null is
missing after popd
* 3305 FIX: cmciii.phase: fixed wrong datatype handling
+ * 3107 FIX: heartbeat_crm: fixed incorrect timezone handling...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/heartbeat_crm b/checks/heartbeat_crm
index 6ec009c..a12380e 100644
--- a/checks/heartbeat_crm
+++ b/checks/heartbeat_crm
@@ -152,7 +152,7 @@ def check_heartbeat_crm(item, params, info):
# Check the freshness of the crm_mon output and terminate with CRITICAL
# when too old information are found
- dt = time.mktime(time.strptime(last_updated, '%a %b %d %H:%M:%S %Y'))
+ dt = utc_mktime(time.strptime(last_updated, '%a %b %d %H:%M:%S %Y'))
now = time.time()
delta = now - dt
if delta > params['max_age']:
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 991338f..d6de68b 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -2053,6 +2053,11 @@ def ensure_directory(path):
return
raise
+# like time.mktime but assumes the time_struct to be in utc, not in local time.
+def utc_mktime(time_struct):
+ import calendar
+ return calendar.timegm(time_struct)
+
#.
# .--Check helpers-------------------------------------------------------.
# | ____ _ _ _ _ |