Module: check_mk
Branch: master
Commit: 0d288c65702c14c54cb740df0c8ee1b853d473a7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0d288c65702c14…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Aug 19 13:02:30 2013 +0200
ups self tests finished
---
checks/apc_symmetra | 10 +++---
checks/apc_symmetra_test | 63 +++++++---------------------------
checks/ups_test | 15 ++++----
web/plugins/wato/check_parameters.py | 32 ++++++++---------
4 files changed, 42 insertions(+), 78 deletions(-)
diff --git a/checks/apc_symmetra b/checks/apc_symmetra
index 1dda539..7172e3b 100644
--- a/checks/apc_symmetra
+++ b/checks/apc_symmetra
@@ -44,7 +44,7 @@
# 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, 0, 0 )
+apc_default_levels = ( 95, 40, 1, 220 )
def check_apc(item, params, info):
BasicBatteryStatus, BasicOutputStatus, AdvBatteryCapacity, \
@@ -53,7 +53,7 @@ def check_apc(item, params, info):
= [ saveint(x) for x in info[0][:9] ]
RunTimeRemaining = AdvBatteryRunTimeRemaining / 100
- crit_capacity, crit_batt_temp, crit_batt_curr, crit_voltage = params[0:4]
+ crit_capacity, crit_batt_temp, crit_batt_curr, crit_voltage = params
single_states = []
@@ -72,8 +72,9 @@ def check_apc(item, params, info):
6:"software bypass", 7:"off",
8:"rebooting", 9:"switched bypass",
10:"hardware failure bypass", 11:"sleeping until power
return",
12:"on smart trim" }
- calib_text = { 1:"", 2:"/calibration invalid",
3:"/calibration in progress" }
+ calib_text = { 1:"", 2:" (calibration invalid)", 3:"
(calibration in progress)" }
infotxt = "output status: %s%s" % (status_text.get(BasicOutputStatus),
calib_text.get(AdvTestCalibrationResults))
+ # during calibration test is OK
if BasicOutputStatus not in [2, 4, 12] and AdvTestCalibrationResults != 3:
state = 2
infotxt += "(!!)"
@@ -124,7 +125,8 @@ def check_apc(item, params, info):
# RunTimeRemaining formatiert == "26:00.00"
hrs = int(RunTimeRemaining) / 3600
mins, secs = divmod(int(RunTimeRemaining) % 3600, 60)
- single_states.append( (0, "run time remaining: %02d:%02d:%02d" % (hrs,
mins, secs), ("runtime", RunTimeRemaining/60)) )
+ single_states.append( (0, "run time remaining: %02d:%02d:%02d" % (hrs,
mins, secs),
+ ("runtime", RunTimeRemaining/60)) )
# create summary state
worst_state = max([x[0] for x in single_states])
diff --git a/checks/apc_symmetra_test b/checks/apc_symmetra_test
index e9597e7..3b18dca 100644
--- a/checks/apc_symmetra_test
+++ b/checks/apc_symmetra_test
@@ -40,7 +40,7 @@
# 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
@@ -50,55 +50,19 @@
# "The date the last UPS diagnostics test was performed in
# mm/dd/yy format."
# ::= { upsAdvTest 4 }
-#
-
-# PowerNet-MIB::upsAdvTestCalibrationResults .1.3.6.1.4.1.318.1.1.1.7.2.6
-# upsAdvTestCalibrationResults OBJECT-TYPE
-# SYNTAX INTEGER {
-# ok(1),
-# invalidTest(2),
-# calibrationInProgress(3)
-# }
-# ACCESS read-only
-# STATUS mandatory
-# DESCRIPTION
-# "The results of the last runtime calibration.
-#
-# Value ok(1) means a successful runtime calibration.
-#
-# Value invalidTest(2) indicates last calibration did
-# not take place since the battery capacity was below
-# 100%.
-#
-# Value calibrationInProgress(3) means a calibration
-# is occurring now. "
-# ::= { upsAdvTest 6 }
-
-# PowerNet-MIB::upsAdvTestCalibrationDate .1.3.6.1.4.1.318.1.1.1.7.2.7
-# upsAdvTestCalibrationDate OBJECT-TYPE
-# SYNTAX DisplayString
-# ACCESS read-only
-# STATUS mandatory
-# DESCRIPTION
-# "The date the last UPS runtime calibration was
-# performed in mm/dd/yy format."
-# ::= { upsAdvTest 7 }
-
-
-
-# levels refer to the apc_symentra group which has 6 values,
-# only the last two are needed in this test
-# the others belong to the apc_symmetra check
+#
import datetime
-apc_test_default_levels = ( 0, 0, 0, 0, 0, 0 )
+ups_test_default = ( 0, 0 )
def check_apc_test(item, params, info):
- warn, crit = params[4:]
+ warn, crit = params
+ if not info:
+ return 3, "Data Missing"
line = info[0]
- DiagnosticsResults, CalibrationResults = map(saveint, line[0:2])
- LastDiagnosticsDate, TestCalibrationDate = line[2:4]
+ DiagnosticsResults = saveint(line[0])
+ LastDiagnosticsDate = line[1]
month, day, year = map(saveint, LastDiagnosticsDate.split('/'))
last_diag_date = datetime.date( year, month, day)
@@ -108,7 +72,6 @@ def check_apc_test(item, params, info):
dwarn = datetime.timedelta(days=warn)
diagnostic_status_text = { 1:"OK", 2:"failed",
3:"invalid", 4:"in progress" }
- calibration_status_text = { 1:"OK", 2:"invalid", 3:"in
progress" }
state = 0
diag_label = ""
@@ -133,16 +96,16 @@ def check_apc_test(item, params, info):
return (state, ResultsDetail )
def inventory_apc_test(info):
- if len(info) > 0:
- return [(None, "apc_test_default_levels")]
+ if info:
+ return [(None, "ups_test_default")]
check_info['apc_symmetra_test'] = {
"inventory_function" : inventory_apc_test,
"check_function" : check_apc_test,
- "service_description" : "APC Symmetra Test Status",
+ "service_description" : "Self Test",
"has_perfdata" : False,
- "group" : "apc_symentra",
+ "group" : "ups_test",
"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.7.2", [ 3,6,4,7 ]
)
+ "snmp_info" : (".1.3.6.1.4.1.318.1.1.1.7.2", [ 3,4 ] )
}
diff --git a/checks/ups_test b/checks/ups_test
index e36a881..f08c89b 100644
--- a/checks/ups_test
+++ b/checks/ups_test
@@ -89,14 +89,16 @@
# TestResultsSummary is noTestsInitiated(6),
# upsTestElapsedTime has the value 0."
-ups_test_default = (None, None )
+ups_test_default = ( 0, 0 )
def inventory_ups_test(info):
- if len(info) > 0:
+ if info:
return [ (None, "ups_test_default") ]
def check_ups_test(item, params, info):
warn, crit = params
+ if not info:
+ return 3, "Data Missing"
line = info[0]
ResultsSummary, StartTime, ElapsedTime = map(saveint, line[:-1])
ElapsedTime = ElapsedTime/100
@@ -112,22 +114,21 @@ def check_ups_test(item, params, info):
state_label = "(!)"
time_label = ""
- if crit and ElapsedTime >= crit:
+ if crit and ElapsedTime >= crit*86400:
state = 2
time_label = "(!!)"
- elif warn and ElapsedTime >= warn:
+ elif warn and ElapsedTime >= warn*86400:
state = max(state, 1)
time_label = "(!)"
ResultsDetail = "%s%s Time elapsed since test: %s%s" % (line[-1],
state_label, etime, time_label)
- #perf = [ ( "ElapsedTime", ElapsedTime, warn, crit) ]
- return (state, ResultsDetail )
+ return state, ResultsDetail
check_info['ups_test'] = {
"inventory_function" : inventory_ups_test,
"check_function" : check_ups_test,
- "service_description" : "UPS Test",
+ "service_description" : "Self Test",
"has_perfdata" : False,
"group" : "ups_test",
"snmp_info" : ( ".1.3.6.1.2.1.33.1.7", [3,5,6,4 ] ),
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index c2862e3..7d66bf3 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -705,8 +705,20 @@ register_check_parameters(
Tuple(
title = _("Time since last UPS selftest"),
elements = [
- Age(title = _("Warning if above")),
- Age(title = _("Critical if above")),
+ Integer(
+ title = _("Warning Level for time since last self test"),
+ help = _("Warning Level for time since last diagnostic test of the
device. "
+ "For a value of 0 the warning level will not be
used"),
+ unit = _("days"),
+ default_value = 0,
+ ),
+ Integer(
+ title = _("Critical Level for time since last self test"),
+ help = _("Critical Level for time since last diagnostic test of the
device. "
+ "For a value of 0 the critical level will not be
used"),
+ unit = _("days"),
+ default_value = 0,
+ ),
]
),
None,
@@ -2878,7 +2890,7 @@ register_check_parameters(
)
register_check_parameters(
- subgroup_os,
+ subgroup_environment,
"apc_symentra",
_("APC Symmetra Checks"),
Tuple(
@@ -2907,20 +2919,6 @@ register_check_parameters(
unit = _("V"),
default_value = 220,
),
- Integer(
- title = _("Warning Level for time since last diagnostic
test"),
- help = _("Warning Level for time since last diagnostic test of the
device. "
- "For a value of 0 the warning level will not be
used"),
- unit = _("days"),
- default_value = 0,
- ),
- Integer(
- title = _("Critical Level for time since last diagnostic
test"),
- help = _("Critical Level for time since last diagnostic test of the
device. "
- "For a value of 0 the critical level will not be
used"),
- unit = _("days"),
- default_value = 0,
- ),
]
),
None,