Module: check_mk
Branch: master
Commit: db3f4898b2233a9ffadad1d3e9543c134f06f8ec
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db3f4898b2233a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 9 10:49:05 2014 +0100
#1730 FIX apc_symmetra: Fixed exception when last diagnose date was not known
---
.werks/1730 | 9 +++++++++
ChangeLog | 1 +
checks/apc_symmetra | 21 ++++++++++-----------
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/.werks/1730 b/.werks/1730
new file mode 100644
index 0000000..d83d1db
--- /dev/null
+++ b/.werks/1730
@@ -0,0 +1,9 @@
+Title: apc_symmetra: Fixed exception when last diagnose date was not known
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1418118509
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index f36b86b..611d2c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -140,6 +140,7 @@
* 1727 FIX: cisco_secure: Fixed inventory exception when port security is not
enabled
* 1728 FIX: cisco_temp_perf: Not inventorized anymore for hosts supporting
cisco_temp_sensor
* 1729 FIX: apc_symmetra_test: Cleaned up check, fixed exception when self test date
is zero
+ * 1730 FIX: apc_symmetra: Fixed exception when last diagnose date was not known
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index cc3f4ca..752b6f5 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -85,10 +85,10 @@ def check_apc(item, params, info):
AdvOutputCurrent, AdvBatteryRunTimeRemaining, AdvTestCalibrationResults,
AdvOutputLoad \
= [ saveint(x) for x in info[0][:13] ]
- LastDiagnosticsDate = info[0][-1]
+ last_diag_date = info[0][-1]
RunTimeRemaining = AdvBatteryRunTimeRemaining / 100
- delay_after_test, alt_crit_capacity = None, None
+ alt_crit_capacity = None
# convert old format tuple to dict
if type(params) is tuple:
params = { "levels": params }
@@ -96,14 +96,13 @@ def check_apc(item, params, info):
# new format with up to 6 params in dict
crit_capacity, crit_sys_temp, crit_batt_curr, crit_voltage =
params['levels']
if params.get("post_calibration_levels"):
- delay_after_test =
params['post_calibration_levels']['additional_time_span']
- alt_crit_capacity =
params['post_calibration_levels']['altcapacity']
- month, day, year = map(saveint, LastDiagnosticsDate.split('/'))
- last_diag_date = datetime.date( year, month, day)
- today = datetime.date.today()
- diag_diff = today - last_diag_date
- oneday = datetime.timedelta(days=1)
- delay = datetime.timedelta(minutes=delay_after_test)
+ if last_diag_date != 'Unknown' and len(last_diag_date) in [8, 10]:
+ year_format = len(last_diag_date) == 8 and '%y' or '%Y'
+ last_ts = time.mktime(time.strptime(last_diag_date,
'%m/%d/'+year_format))
+ diff_sec = time.time() - last_ts
+
+ allowed_delay_sec = 86400 +
params['post_calibration_levels']['additional_time_span']
+ alt_crit_capacity =
params['post_calibration_levels']['altcapacity']
single_states = []
@@ -148,7 +147,7 @@ def check_apc(item, params, info):
state = 0
infotxt = "capacity %d%% (crit at " % AdvBatteryCapacity
- if alt_crit_capacity != None and diag_diff < oneday + delay:
+ if alt_crit_capacity != None and diff_sec < allowed_delay_sec:
infotxt += "%d%% in delay after calib.)" % alt_crit_capacity
if AdvBatteryCapacity <= alt_crit_capacity:
state = 2