Module: check_mk
Branch: master
Commit: 505a9dd428e45bcf1348f84250a9aa80763cefe7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=505a9dd428e45b…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Aug 19 12:01:44 2016 +0200
3777 ipmi: IPMI sensor states are configurable
---
.werks/3777 | 9 ++++++
ChangeLog | 1 +
checks/ipmi | 57 ++++++++++++++++++++++------------
web/plugins/wato/check_parameters.py | 28 +++++++++++++++--
4 files changed, 73 insertions(+), 22 deletions(-)
diff --git a/.werks/3777 b/.werks/3777
new file mode 100644
index 0000000..23972cc
--- /dev/null
+++ b/.werks/3777
@@ -0,0 +1,9 @@
+Title: ipmi: IPMI sensor states are configurable
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i1
+Date: 1471600864
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 1613e05..cfa2fb9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -131,6 +131,7 @@
* 3776 check_mail_loop: now you can specify the subject text instead of default
'Check_MK-Mail-Loop'
* 2242 fortigate_sessions, fortigate_sessions_base: Allow configuration of levels for
sessions
* 3842 juniper_cpu_util: Allow configuratioh of level for routing engine
+ * 3777 ipmi: IPMI sensor states are configurable
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/checks/ipmi b/checks/ipmi
index 9f76df2..c660fcd 100644
--- a/checks/ipmi
+++ b/checks/ipmi
@@ -187,7 +187,7 @@ def check_ipmi(item, params, info):
if item == "Summary":
return check_ipmi_summarized(parsed, params)
else:
- return check_ipmi_detailed(item, parsed)
+ return check_ipmi_detailed(item, params, parsed)
def ipmi_format_message(status, val, unit):
@@ -203,8 +203,8 @@ def ipmi_format_message(status, val, unit):
return infotext
-def check_ipmi_detailed(item, parsed):
- for name, val, unit, status, unrec_low, crit_low, \
+def check_ipmi_detailed(item, params, parsed):
+ for name, val, unit, status_txt, unrec_low, crit_low, \
warn_low, warn_high, crit_high, unrec_high in parsed:
if name == item:
@@ -213,18 +213,23 @@ def check_ipmi_detailed(item, parsed):
else:
perfdata = []
- if status.startswith('ok') and not "failure detected" in
status.lower():
+ if status_txt.startswith('ok') and not "failure detected"
in status_txt.lower():
state = 0
- elif status.startswith('nc'):
+ elif status_txt.startswith('nc'):
state = 1
else:
state = 2
- return state, "Status: %s" % ipmi_format_message(status, val,
unit), perfdata
+ for wato_status_txt, wato_status in params.get("sensor_states",
[]):
+ if status_txt.startswith(wato_status_txt):
+ state = wato_status
+ break
+
+ return state, "Status: %s" % ipmi_format_message(status_txt, val,
unit), perfdata
def check_ipmi_summarized(parsed, params):
- worst_status = 0
+ worst_state = 0
warn_texts = []
crit_texts = []
count = 0
@@ -234,30 +239,41 @@ def check_ipmi_summarized(parsed, params):
if 'ignored_sensors' not in params:
params['ignored_sensors'] = ipmi_get_ignored_sensors(g_hostname)
- for name, val, unit, status, unrec_low, crit_low, \
+ for name, val, unit, status_txt, unrec_low, crit_low, \
warn_low, warn_high, crit_high, unrec_high in parsed:
# Skip datasets which have no valid data (zero value, no unit and state nc)
- if val == '0.000' and unit == 'unspecified' and
status.startswith('nc'):
+ if val == '0.000' and unit == 'unspecified' and
status_txt.startswith('nc'):
continue
- if ipmi_ignore_entry(name, status, params['ignored_sensors']):
+ if ipmi_ignore_entry(name, status_txt, params['ignored_sensors']):
continue
- count += 1
- infotext = "%s (%s)" % (name, ipmi_format_message(status, val, unit))
+ count += 1
+ infotext = "%s (%s)" % (name, ipmi_format_message(status_txt, val,
unit))
+ tmp_state = 0
- if status.startswith('nc'):
- worst_status = max(worst_status, 1)
- warn_texts.append(infotext)
+ if status_txt.startswith('nc'):
+ tmp_state = 1
- elif status.startswith('nr') and ipmi_ignore_nr:
+ elif status_txt.startswith('nr') and ipmi_ignore_nr:
pass
- elif not status.startswith('ok') or "failure detected" in
status.lower():
- worst_status = 2
+ elif not status_txt.startswith('ok') or "failure detected" in
status_txt.lower():
+ tmp_state = 2
+
+ for wato_status_txt, wato_status in params.get("sensor_states", []):
+ if status_txt.startswith(wato_status_txt):
+ tmp_state = wato_status
+ break
+
+ if tmp_state == 1:
+ warn_texts.append(infotext)
+ elif tmp_state == 2:
crit_texts.append(infotext)
+ worst_state = max(worst_state, tmp_state)
+
if "amb" in name or "Ambient" in name:
try:
ambient_count += 1
@@ -270,7 +286,7 @@ def check_ipmi_summarized(parsed, params):
else:
perfdata = []
- if worst_status == 0:
+ if worst_state == 0:
infotexts = [ "%d sensors OK" % count ]
else:
@@ -280,7 +296,7 @@ def check_ipmi_summarized(parsed, params):
if len(warn_texts) > 0:
infotexts.append("WARN are: %s" % ", ".join(warn_texts))
- return worst_status, ' - '.join(infotexts), perfdata
+ return worst_state, ' - '.join(infotexts), perfdata
def ipmi_precompile(hostname, item, params):
@@ -305,6 +321,7 @@ check_info["ipmi"] = {
'service_description' : 'IPMI Sensor %s',
'has_perfdata' : True,
'extra_sections' : [ "ipmi_discrete" ],
+ 'group' : 'ipmi'
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index fdbb6f4..8aab886 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -253,8 +253,8 @@ register_rule(group + '/' + subgroup_inventory,
elements = [
( "ignored_sensors",
ListOfStrings(
- title = _("Ignore the following IPMI Sensors"),
- help = _("Names of IPMI Sensors that should be ignored during
inventory "
+ title = _("Ignore the following IPMI sensors"),
+ help = _("Names of IPMI sensors that should be ignored during
inventory "
"and when summarizing."
"The pattern specified here must match exactly the
beginning of "
"the actual sensor name (case sensitive)."),
@@ -1909,6 +1909,30 @@ register_check_parameters(
match_type = "dict",
)
+register_check_parameters(
+ subgroup_environment,
+ "ipmi",
+ _("IPMI sensors"),
+ Dictionary(
+ elements = [
+ ("sensor_states",
+ ListOf(
+ Tuple(
+ elements = [
+ TextAscii(), MonitoringState()
+ ]
+ ),
+ title = _("Set states of IPMI sensor status texts"),
+ help = _("The pattern specified here must match exactly the
beginning of "
+ "the sensor state (case sensitive)."),
+ orientation = "horizontal",
+ )
+ ),
+ ]
+ ),
+ TextAscii(title = _("The sensor name.")),
+ "dict",
+)
register_check_parameters(
subgroup_environment,