Module: check_mk
Branch: master
Commit: b6b64eecf057bceacbca697f9edfe5b4de8428ae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b6b64eecf057bc…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Sat Oct 3 15:16:46 2015 +0200
#2433 interface checks: now able to configure the infotext shown in the check output
You can now configure with the WATO rule <i>Network interfaces and switch
ports</i> the
infotext between the [] brackets. The following options are available.
<ul>
<li>Show alias</li>
<li>Show description</li>
<li>Show alias and description</li>
<li>Show alias if set, else description</li>
<li>Show description if set, else alias</li>
<li>Hide infotext</li>
</ul>
---
.werks/2433 | 19 ++++++++++++++
ChangeLog | 1 +
checks/if.include | 47 ++++++++++++++++++++++++----------
web/plugins/wato/check_parameters.py | 16 ++++++++++++
4 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/.werks/2433 b/.werks/2433
new file mode 100644
index 0000000..6532a8a
--- /dev/null
+++ b/.werks/2433
@@ -0,0 +1,19 @@
+Title: interface checks: now able to configure the infotext shown in the check output
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1443877893
+Class: feature
+
+You can now configure with the WATO rule <i>Network interfaces and switch
ports</i> the
+infotext between the [] brackets. The following options are available.
+
+<ul>
+<li>Show alias</li>
+<li>Show description</li>
+<li>Show alias and description</li>
+<li>Show alias if set, else description</li>
+<li>Show description if set, else alias</li>
+<li>Hide infotext</li>
+</ul>
diff --git a/ChangeLog b/ChangeLog
index 662364b..a23c8e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -94,6 +94,7 @@
* 2634 artec_disk, artec_documents, artec_load, artec_mem, artec_processes,
artec_temp: new checks for ARTEC Mail Archive Appliance...
* 2632 oracle_diva_csm, oracle_diva_csm.actor, oracle_diva_csm.archive,
oracle_diva_csm.drive: new checks for DIVA CSM devices
* 2635 pandacom_psu, pandacom_fan, pandacom_sys_temp, pandacom_10gm_temp,
pandacom_fc_temp: new checks for Pandacom SpeedCarrier Chassis 5u...
+ * 2433 interface checks: now able to configure the infotext shown in the check
output...
* 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/if.include b/checks/if.include
index ae416f9..87422f2 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -576,20 +576,41 @@ def check_if_common_single(item, params, info, force_counter_wrap =
False,
# The detailed group info is added later on
infotext = group_name + " Status "
else:
- # Display port number or alias in infotext if that is not part
- # of the service description anyway
- if item.lstrip("0") == ifIndex \
- and (item == ifAlias or ifAlias == '') \
- and (item == ifDescr or ifDescr == ''): # description
trivial
- infotext = ""
- elif item == "%s %s" % (ifAlias, ifIndex) and ifDescr !=
'': # non-unique Alias
- infotext = "[%s/%s]" % (ifAlias, ifDescr)
- elif item != ifAlias and ifAlias != '': # alias useful
- infotext = "[%s] " % ifAlias
- elif item != ifDescr and ifDescr != '': # description useful
- infotext = "[%s] " % ifDescr
+ if "infotext_format" in params:
+ bracket_info = ""
+ if params["infotext_format"] == "alias":
+ bracket_info = ifAlias
+ elif params["infotext_format"] == "description":
+ bracket_info = ifDescr
+ elif params["infotext_format"] ==
"alias_and_description":
+ bracket_info = []
+ ifAlias and bracket_info.append(ifAlias)
+ ifDescr and bracket_info.append(ifDescr)
+ bracket_info = ", ".join(bracket_info)
+ elif params["infotext_format"] ==
"alias_or_description":
+ bracket_info = ifAlias and ifAlias or ifDescr
+ elif params["infotext_format"] ==
"desription_or_alias":
+ bracket_info = ifDescr and ifDescr or ifAlias
+
+ if bracket_info:
+ infotext = "[%s]" % bracket_info
+ else:
+ infotext = ""
else:
- infotext = "[%s] " % ifIndex
+ # Display port number or alias in infotext if that is not part
+ # of the service description anyway
+ if item.lstrip("0") == ifIndex \
+ and (item == ifAlias or ifAlias == '') \
+ and (item == ifDescr or ifDescr == ''): # description
trivial
+ infotext = ""
+ elif item == "%s %s" % (ifAlias, ifIndex) and ifDescr !=
'': # non-unique Alias
+ infotext = "[%s/%s]" % (ifAlias, ifDescr)
+ elif item != ifAlias and ifAlias != '': # alias useful
+ infotext = "[%s] " % ifAlias
+ elif item != ifDescr and ifDescr != '': # description useful
+ infotext = "[%s] " % ifDescr
+ else:
+ infotext = "[%s] " % ifIndex
if node != None:
infotext = "%son %s: " % ( infotext, node )
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 0262b3f..95084a3 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3291,6 +3291,22 @@ register_check_parameters(
( "bit", _("Bits") ),
( "byte", _("Bytes") ),],
)),
+ ( "infotext_format",
+ DropdownChoice(
+ title = _("Change infotext in check output"),
+ help = _("This setting allows you to modify the information
text which is displayed between "
+ "the two brackets in the check output. Please note
that this setting does not work for "
+ "grouped interfaces, since the additional
information of grouped interfaces is different"),
+ choices = [
+ ("alias", _("Show
alias")),
+ ("description", _("Show
description")),
+ ("alias_and_description", _("Show alias and
description")),
+ ("alias_or_description", _("Show alias if
set, else description")),
+ ("desription_or_alias", _("Show description
if set, else alias")),
+ ("hide", _("Hide
infotext")),
+ ]
+ )
+ ),
( "traffic",
ListOf(CascadingDropdown(
title = _("Direction"),