Module: check_mk
Branch: master
Commit: 6aed363bb47ebb97a70714028e14279ad307194b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6aed363bb47ebb…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Sep 23 15:03:36 2013 +0200
new check feature: alternative battery level in post-calibration phase
---
checks/apc_symmetra | 70 ++++++++++++++++++++++-----
web/plugins/wato/check_parameters.py | 86 ++++++++++++++++++++++++----------
2 files changed, 119 insertions(+), 37 deletions(-)
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index fb31375..5a9a5b8 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -41,19 +41,59 @@
# hardwareFailureBypass(10), sleepingUntilPowerReturn(11), onSmartTrim(12)
# upsAdvTestCalibrationResults: ok(1), invalidTest(2), calibrationInProgress(3)
-# levels refer to the apc_symentra group which has 6 values,
-# only the first four are needed in this test
-# the others belong to the apc_symmetra_test check
-apc_default_levels = ( 95, 40, 1, 220 )
+# PowerNet-MIB::upsAdvTestDiagnosticsResults .1.3.6.1.4.1.318.1.1.1.7.2.3
+# upsAdvTestDiagnosticsResults OBJECT-TYPE
+# SYNTAX INTEGER {
+# ok(1),
+# failed(2),
+# invalidTest(3),
+# testInProgress(4)
+# }
+# ACCESS read-only
+# STATUS mandatory
+# DESCRIPTION
+# "The results of the last UPS diagnostics test performed."
+# ::= { upsAdvTest 3 }
+
+# PowerNet-MIB::upsAdvTestLastDiagnosticsDate .1.3.6.1.4.1.318.1.1.1.7.2.4
+# upsAdvTestLastDiagnosticsDate OBJECT-TYPE
+# SYNTAX DisplayString
+# ACCESS read-only
+# STATUS mandatory
+# DESCRIPTION
+# "The date the last UPS diagnostics test was performed in
+# mm/dd/yy format."
+# ::= { upsAdvTest 4 }
+#
+
+# altes Format:
+# apc_default_levels = ( 95, 40, 1, 220 )
+
+apc_default_levels = { "levels": ( 95, 40, 1, 220 ) }
def check_apc(item, params, info):
BasicBatteryStatus, BasicOutputStatus, AdvBatteryCapacity, \
AdvBatteryTemperature, AdvBatteryCurrent, AdvOutputVoltage, \
AdvOutputCurrent, AdvBatteryRunTimeRemaining, AdvTestCalibrationResults \
= [ saveint(x) for x in info[0][:9] ]
+
+ LastDiagnosticsDate = info[0][-1]
RunTimeRemaining = AdvBatteryRunTimeRemaining / 100
- crit_capacity, crit_batt_temp, crit_batt_curr, crit_voltage = params
+ delay_after_test, alt_crit_capacity = None, None
+ if len(params) == 4 and type(params) is tuple: # früher gab es 4 Parameter im tuple
+ crit_capacity, crit_batt_temp, crit_batt_curr, crit_voltage = params
+ else: # nun sind es 6 im dict
+ crit_capacity, crit_batt_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)
single_states = []
@@ -83,12 +123,20 @@ def check_apc(item, params, info):
single_states.append( (state, infotxt, None) )
# 3. Check battery capacity
- infotxt = "capacity %d%%" % AdvBatteryCapacity
- if AdvBatteryCapacity <= crit_capacity:
- state = 2
- infotxt += "(!!)"
+ state = 0
+ infotxt = "capacity %d%% (crit at " % AdvBatteryCapacity
+
+ if alt_crit_capacity != None and diag_diff < oneday + delay:
+ infotxt += "%d%% in delay after calib.)" % alt_crit_capacity
+ if AdvBatteryCapacity <= alt_crit_capacity:
+ state = 2
+ infotxt += "(!!)"
else:
- state = 0
+ infotxt += "%d%%)" % crit_capacity
+ if AdvBatteryCapacity <= crit_capacity:
+ state = 2
+ infotxt += "(!!)"
+
single_states.append( (state, infotxt, ("capacity", AdvBatteryCapacity,
"", crit_capacity, 0, 100)) )
# 4. Check battery temperature
@@ -148,5 +196,5 @@ check_info['apc_symmetra'] = {
"snmp_scan_function" : lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.318.1.3"),
"snmp_info" : (".1.3.6.1.4.1.318.1.1.1",
[ "2.1.1.0", "4.1.1.0",
"2.2.1.0", "2.2.2.0",
- "2.2.9.0", "4.2.1.0",
"4.2.4.0", "2.2.3.0", "7.2.6.0" ] )
+ "2.2.9.0", "4.2.1.0",
"4.2.4.0", "2.2.3.0", "7.2.6.0", "7.2.4.0" ] )
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index b367fd2..123ed17 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3181,33 +3181,67 @@ register_check_parameters(
subgroup_environment,
"apc_symentra",
_("APC Symmetra Checks"),
- Tuple(
+ Dictionary(
elements = [
- Integer(
- title = _("Critical Battery Capacity"),
- help = _("The battery capacity in percent at and below which a
critical state is be triggered"),
- unit = _("%"),
- default_value = 95,
- ),
- Integer(
- title = _("Critical Battery Temperature"),
- help = _("The critical temperature of the battery"),
- unit = _("C"),
- default_value = 40,
- ),
- Integer(
- title = _("Critical Battery Current"),
- help = _("The critical battery current in Ampere"),
- unit = _("A"),
- default_value = 1,
- ),
- Integer(
- title = _("Critical Battery Voltage"),
- help = _("The output voltage at and below which a critical state is
triggered."),
- unit = _("V"),
- default_value = 220,
- ),
- ]
+ ("levels",
+ Tuple(
+ title = _("Levels of battery parameters during normal
operation"),
+ elements = [
+ Integer(
+ title = _("Critical Battery Capacity"),
+ help = _("The battery capacity in percent at and below which
a critical state is be triggered"),
+ unit = _("%"),
+ default_value = 95,
+ ),
+ Integer(
+ title = _("Critical Battery Temperature"),
+ help = _("The critical temperature of the battery"),
+ unit = _("C"),
+ default_value = 40,
+ ),
+ Integer(
+ title = _("Critical Battery Current"),
+ help = _("The critical battery current in Ampere"),
+ unit = _("A"),
+ default_value = 1,
+ ),
+ Integer(
+ title = _("Critical Battery Voltage"),
+ help = _("The output voltage at and below which a critical
state is triggered."),
+ unit = _("V"),
+ default_value = 220,
+ ),
+ ]
+ )),
+ ("post_calibration_levels",
+ Dictionary(
+ title = _("Levels of battery parameters after calibration"),
+ help = _("After a battery calibration the battery capacity is
reduced until the "
+ "battery is fully charged again. Here you can specify an
alternative lower "
+ "level in this post-calibration phase. "
+ "Since apc devices remember the time of the last
calibration only "
+ "as a date, the alternative lower level will be applied on
the whole "
+ "day of the calibration until midnight. You can extend this
time period "
+ "with an additional time span to make sure calibrations
occuring just "
+ "before midnight do not trigger false alarms."
+ ),
+ elements = [
+ ("altcapacity",
+ Percentage(
+ title = _("Alternative critical battery capacity after
calibration"),
+ default_value = 50,
+ )),
+ ("additional_time_span",
+ Integer(
+ title = ("Extend post-calibration phase by additional time
span"),
+ unit = _("minutes"),
+ default_value = 0,
+ )),
+ ],
+ optional_keys = False,
+ )),
+ ],
+ optional_keys = ['post_calibration_levels'],
),
None,
"first"