Module: check_mk
Branch: master
Commit: c963de5f94d9040cb7c3ff604b3b94b01ef2140a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c963de5f94d904…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Sep 9 09:48:46 2015 +0200
new WATO rule and ibm_imm_fan is now configurable
---
checkman/ibm_imm_fan | 4 ++--
checks/ibm_imm_fan | 40 +++++++++++++++++++++++-----------
web/plugins/wato/check_parameters.py | 32 ++++++++++++++++++++++++++-
3 files changed, 60 insertions(+), 16 deletions(-)
diff --git a/checkman/ibm_imm_fan b/checkman/ibm_imm_fan
index c7ce6c3..1eeae8c 100644
--- a/checkman/ibm_imm_fan
+++ b/checkman/ibm_imm_fan
@@ -8,8 +8,8 @@ description:
Integrated Management Module (IMM). It uses snmp and the IBM IMM MIB to
gather the fan data.
- The check uses hardcoded lower warning and critical levels of (28%,25%)
- to calculate the state of the service.
+ The lower default levels are set to 28%/25%.
+ Upper and lower levels are configurable.
inventory:
The service discovery will find one service per fan
diff --git a/checks/ibm_imm_fan b/checks/ibm_imm_fan
index 6f8d4e4..ac097c7 100644
--- a/checks/ibm_imm_fan
+++ b/checks/ibm_imm_fan
@@ -24,14 +24,14 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-
+ibm_imm_fan_default_levels = (28, 25)
def inventory_ibm_imm_fan(info):
for descr, speed in info:
if speed.lower() != 'offline':
- yield descr, {}
+ yield descr, "ibm_imm_fan_default_levels"
-def check_ibm_imm_fan(item, _no_params, info):
+def check_ibm_imm_fan(item, params, info):
for descr, speed in info:
if descr == item:
@@ -43,17 +43,30 @@ def check_ibm_imm_fan(item, _no_params, info):
rpm_perc = int(speed.strip().replace("[\"%]", "
").replace("%", " ").split(" ")[0])
infotext = "%d%% of max rpm" % rpm_perc
- warn, crit = (28, 25) # preliminary estimates of levels
- levelstext = " (warn/crit at %d%%/%d%%)" % (warn,crit)
+ state = 0
+ levels_info = ""
+ if type(params) == tuple:
+ params = {'levels_lower' : params}
+
+ warn_lower, crit_lower = params.get('levels_lower', (None, None))
+ warn, crit = params.get('levels', (None, None))
+
+ if warn_lower:
+ if rpm_perc <= crit_lower:
+ state = 2
+ elif rpm_perc <= warn_lower:
+ state = 1
+ levels_info += " (warn/crit below %d%%/%d%%)" % (warn_lower,
crit_lower)
+
+ if warn:
+ if rpm_perc >= crit:
+ state = 2
+ elif rpm_perc >= warn:
+ state = 1
+ levels_info += " (warn/crit at %d%%/%d%%)" % (warn, crit)
- if rpm_perc <= crit:
- state = 2
- infotext += levelstext
- elif rpm_perc <= warn:
- state = 1
- infotext += levelstext
- else:
- state = 0
+ if state > 0:
+ infotext += levels_info
return state, infotext
@@ -68,4 +81,5 @@ check_info["ibm_imm_fan"] = {
2, # fanDescr
3, # fanSpeed
]),
+ 'group' : 'hw_fans_perc',
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 9638b68..faf693b 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -7055,7 +7055,7 @@ register_check_parameters(
),
( "upper",
Tuple(
- help = _("Upper levels for the Fan speed of a hardware
device"),
+ help = _("Upper levels for the fan speed of a hardware
device"),
title = _("Upper levels"),
elements = [
Integer(title = _("warning at"), unit = u"rpm",
default_value = 8000),
@@ -7072,6 +7072,36 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_environment,
+ "hw_fans_perc",
+ _("Fan speed of hardware devices (in percent)"),
+ Dictionary(
+ elements = [
+ ( "levels",
+ Tuple(
+ title = _("Upper fan speed levels"),
+ elements = [
+ Percentage(title = _("warning if at")),
+ Percentage(title = _("critical if at")),
+ ]
+ )),
+ ( "levels_lower",
+ Tuple(
+ title = _("Lower fan speed levels"),
+ elements = [
+ Percentage(title = _("warning if below")),
+ Percentage(title = _("critical if below")),
+ ]
+ )),
+ ]
+ ),
+ TextAscii(
+ title = _("Fan Name"),
+ help = _("The identifier of the fan.")),
+ "dict",
+)
+
+register_check_parameters(
subgroup_os,
"pf_used_states",
_("Number of used states of OpenBSD PF engine"),