Module: check_mk
Branch: master
Commit: f0faaa4cc16dd0b758b585a08bfddbe59142ab74
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0faaa4cc16dd0…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Fri Aug 7 15:50:22 2015 +0200
cleanup in ipmi check
now also allows disabling summarization from web interface and
restructured configuration variable.
---
.werks/2523 | 2 +-
ChangeLog | 2 +-
checks/ipmi | 43 ++++++++++++++++++++--------------
web/plugins/wato/check_parameters.py | 39 ++++++++++++++++++++++--------
4 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/.werks/2523 b/.werks/2523
index 9bc513a..9854203 100644
--- a/.werks/2523
+++ b/.werks/2523
@@ -1,4 +1,4 @@
-Title: ipmi: new wato rule to set ignored sensors
+Title: ipmi: new wato rule to set ignored sensors and activate/deactivate summarizing
Level: 1
Component: checks
Compatible: compat
diff --git a/ChangeLog b/ChangeLog
index af9704c..28d9282 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,7 +38,7 @@
* 2513 new checks sentry_pdu_outlets sentry_pdu_systempower: monitor the system power
consumption and outlet states of sentry pdu devices which support the Sentry3-MIB
* 2515 juniper_trpz_aps: check is now cluster-aware...
* 2417 winperf_phydisk: can now work in a cluster environment
- * 2523 ipmi: new wato rule to set ignored sensors
+ * 2523 ipmi: new wato rule to set ignored sensors and activate/deactivate
summarizing
* 2315 FIX: windows agent: BOM replacement, fixed incorrect byte offset...
* 2316 FIX: windows agent: fix garbled output of cached agent plugins...
* 2358 FIX: check_mk_agent.solaris: more correct computation of zfs used space...
diff --git a/checks/ipmi b/checks/ipmi
index 5e33655..98a823e 100644
--- a/checks/ipmi
+++ b/checks/ipmi
@@ -97,16 +97,16 @@
ipmi_summarize = True
ipmi_ignore_nr = False # set to True in order to ignore entries with state 'nr'
ipmi_ignored_sensors = [] # example: [ "Power_Meter", "Virtual_Fan"
]
-ipmi_ignored_sensors_wato = [] # ignored sensors specified from wato
-
-def ignored_sensors():
- # merge ignored sensor list specified here and those from wato
- ignored_sensors_combined = ipmi_ignored_sensors[:]
- if ipmi_ignored_sensors_wato:
- ignored_sensors_combined += host_extra_conf(g_hostname,
ipmi_ignored_sensors_wato)[0]
- return ignored_sensors_combined
+inventory_ipmi_rules = []
def ipmi_ignore_entry(name, state):
+ def ignored_sensors():
+ # merge ignored sensor list specified here and those from wato
+ ignored_sensors_combined = ipmi_ignored_sensors[:]
+ rules = host_extra_conf(g_hostname, inventory_ipmi_rules)[0]
+ ignored_sensors_combined += rules.get("ignored_sensors", [])
+ return ignored_sensors_combined
+
if ipmi_ignore_nr and state == 'nr':
return True
for e in ignored_sensors():
@@ -115,12 +115,15 @@ def ipmi_ignore_entry(name, state):
return False
def inventory_ipmi(info):
- if ipmi_summarize and len(info) > 0:
- return [ ( "Summary", None ) ]
- else:
+ rules = host_extra_conf(g_hostname, inventory_ipmi_rules)[0]
+ # the default for summarize is always true so if either configuration key has been
set
+ # to false that setting was changed by the user and needs to override the other
+ if not ipmi_summarize or not rules.get("summarize", True) or len(info) ==
0:
return [ ( line[0], None )
for line in info
if not ipmi_ignore_entry(line[0], line[3]) ]
+ else:
+ return [ ( "Summary", None ) ]
def check_ipmi(item, params, info):
if item == "Summary":
@@ -128,17 +131,25 @@ def check_ipmi(item, params, info):
else:
return check_ipmi_detailed(item, info)
+def ipmi_format_message(name, val, unit):
+ text = "%s is %s" % (name, val)
+ if unit != 'unspecified':
+ text += ' %s' % unit
+ # otherwise the unit is unknown or there is none (val could represent yes/no)
+ return text
+
+
def check_ipmi_detailed(item, info):
for name, val, unit, status, unrec_low, crit_low, \
warn_low, warn_high, crit_high, unrec_high in info:
if name == item:
perfdata = [ (name, val + unit) ] # TODO: add warn and crit levels
if status == 'ok':
- return (0, "%s is %s %s" % (name, val, unit), perfdata)
+ return (0, ipmi_format_message(name, val, unit), perfdata)
elif status == 'nc':
- return (1, "%s is %s %s" % (name, val, unit), perfdata)
+ return (1, ipmi_format_message(name, val, unit), perfdata)
else:
- return (2, "%s is %s %s" % (name, val, unit), perfdata)
+ return (2, ipmi_format_message(name, val, unit), perfdata)
def check_ipmi_summarized(info):
worst_status = 0
@@ -157,10 +168,8 @@ def check_ipmi_summarized(info):
if ipmi_ignore_entry(name, status):
continue
- text = "%s is %s" % (name, val)
- if unit != 'unspecified':
- text += ' %s' % unit
count += 1
+ text = ipmi_format_message(name, val, unit)
if status == 'nc':
worst_status = max(worst_status, 1)
warn_texts.append(text)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index cde6176..817beb7 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -88,16 +88,35 @@ register_rule(group + "/" + subgroup_networking,
# '----------------------------------------------------------------------'
register_rule(group + '/' + subgroup_inventory,
- varname = "ipmi_ignored_sensors_wato",
- title = _("Discovery of IPMI sensors"),
- valuespec = ListOfStrings(
- title = _("Ignore the following IPMI Sensors"),
- help = _("Names of IPMI Sensors that should be ignored during
inventory. "
- "The pattern specified here must match exactly the begin of
"
- "the actual sensor name (case sensitive)."),
- orientation = "horizontal"
- ),
- match = 'first')
+ varname = "inventory_ipmi_rules",
+ title = _("Discovery of IPMI sensors"),
+ valuespec = Dictionary(
+ show_titles = True,
+ elements = [
+ ( "ignored_sensors",
+ ListOfStrings(
+ 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)."),
+ orientation = "horizontal"
+ )
+ ),
+ ( "summarize",
+ Checkbox(
+ title = _("Display only a summary of all sensors"),
+ label = _("Summarize"),
+ help = _("If active, only a single summary item is displayed.
The summary "
+ "will explicitly mention sensors in warn/crit state
but the "
+ "sensors that are ok are aggregated."),
+ default_value = True
+ )
+ )
+ ]
+ ),
+ match = 'first'
+)
#.
# .--Applications--------------------------------------------------------.