Module: check_mk
Branch: master
Commit: 6767560fa3e9dbae617b60c4a50bb424c39d6e09
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6767560fa3e9db…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Mar 8 14:09:37 2016 +0100
3259 FIX ad_replication: fixed wrong timestamp handling
---
.werks/3259 | 10 ++++++++++
ChangeLog | 1 +
checks/ad_replication | 31 +++++++++++++++----------------
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/.werks/3259 b/.werks/3259
new file mode 100644
index 0000000..4c0693b
--- /dev/null
+++ b/.werks/3259
@@ -0,0 +1,10 @@
+Title: ad_replication: fixed wrong timestamp handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457442486
+
+
diff --git a/ChangeLog b/ChangeLog
index 71547a6..eb82124 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -68,6 +68,7 @@
* 3277 FIX: veeam_jobs: Handling missing state "Postprocessing" now
* 3278 FIX: fritz_wan_if: Fixed incorrect unit Bit used in check
* 3092 FIX: isc_dhcpd: fixed incorrect handling of timezones
+ * 3259 FIX: ad_replication: fixed wrong timestamp handling
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/ad_replication b/checks/ad_replication
index 7e85bc8..9217837 100644
--- a/checks/ad_replication
+++ b/checks/ad_replication
@@ -38,9 +38,11 @@ ad_replication_default_params = (15,20)
def parse_ad_replication_dates(s):
if s == '0' or s == '(never)':
- return None
+ return None, "unknown"
else:
- return time.mktime(time.strptime(s, '%Y-%m-%d %H:%M:%S'))
+ s_val = time.mktime(time.strptime(s, '%Y-%m-%d %H:%M:%S'))
+ s_txt = get_relative_date_human_readable(s_val)
+ return s_val, s_txt
def parse_ad_replication_info(info):
lines = []
@@ -87,8 +89,8 @@ def check_ad_replication(item, params, info):
if lineType == 'showrepl_INFO' and source_site+'/'+source_dc ==
item:
foundLine = True
- time_last_failure = parse_ad_replication_dates(time_last_failure)
- time_last_success = parse_ad_replication_dates(time_last_success)
+ time_last_failure, time_last_failure_txt =
parse_ad_replication_dates(time_last_failure)
+ time_last_success, time_last_success_txt =
parse_ad_replication_dates(time_last_success)
max_failures_warn = params[0]
max_failures_crit = params[1]
@@ -96,30 +98,27 @@ def check_ad_replication(item, params, info):
if int(num_failures) > max_failures_warn:
status = 1
output += '(!) %s/%s replication of context %s reached ' \
- ' the threshold of maximum failures (%s) (last success: %s,
' \
- 'last failure: %s, num failures: %s Status: %s), ' % \
+ ' the threshold of maximum failures (%s) (Last success: %s,
' \
+ 'Last failure: %s, Num failures: %s, Status: %s), ' %
\
(source_site, source_dc, naming_context, max_failures_warn,
- get_relative_date_human_readable(time_last_success),
- get_relative_date_human_readable(time_last_failure),
num_failures, statusLastFailure)
+ time_last_success_txt, time_last_failure_txt, num_failures,
statusLastFailure)
if int(num_failures) > max_failures_crit:
status = 2
output += '(!!) %s/%s replication of context %s reached ' \
- ' the threshold of maximum failures (%s) (last success: %s,
' \
- 'last failure: %s, num failures: %s, status: %s), ' %
\
+ ' the threshold of maximum failures (%s) (Last success: %s,
' \
+ 'Last failure: %s, Num failures: %s, Status: %s), ' %
\
(source_site, source_dc, naming_context, max_failures_crit,
- get_relative_date_human_readable(time_last_success),
- get_relative_date_human_readable(time_last_failure),
num_failures, statusLastFailure)
+ time_last_success_txt, time_last_failure_txt, num_failures,
statusLastFailure)
if time_last_failure != None and time_last_success != None \
and time_last_failure > time_last_success:
status = 2
output += '(!!) %s/%s replication of context %s failed ' \
- '(last success: %s, last failure: %s num_failures: %s,
status: %s), ' % \
+ '(Last success: %s, Last failure: %s, Num failures: %s,
Status: %s), ' % \
(source_site, source_dc, naming_context,
- get_relative_date_human_readable(time_last_success),
- get_relative_date_human_readable(time_last_failure),
- num_failures, statusLastFailure)
+ time_last_success_txt, time_last_failure_txt, num_failures,
statusLastFailure)
+
if not foundLine:
return (3, 'Replication information for %s not found' % item)