Module: check_mk
Branch: master
Commit: 1169df43c5ec7e0f3e7dabf1bd529b2b6c5d031d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1169df43c5ec7e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Nov 13 09:50:02 2014 +0100
#1509 if, if64: New option for make inventory based on port alias
All interface checks now allow to inventory just those ports whose
alias matches one of a list of regular expressions. These are a new
option in the WATO rule <i>Network Interface and Switch Port Inventory</i>.
This allows you to control which ports are monitored based on the alias
<b>without</b> using the alias as the service description.
---
.werks/1509 | 13 +++++++++++++
ChangeLog | 1 +
checkman/if64 | 2 +-
checks/if.include | 11 ++++++++++-
web/plugins/wato/check_parameters.py | 26 +++++++++++++++++++++-----
5 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/.werks/1509 b/.werks/1509
new file mode 100644
index 0000000..d57236f
--- /dev/null
+++ b/.werks/1509
@@ -0,0 +1,13 @@
+Title: if, if64: New option for make inventory based on port alias
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1415868493
+Class: feature
+
+All interface checks now allow to inventory just those ports whose
+alias matches one of a list of regular expressions. These are a new
+option in the WATO rule <i>Network Interface and Switch Port Inventory</i>.
+This allows you to control which ports are monitored based on the alias
+<b>without</b> using the alias as the service description.
diff --git a/ChangeLog b/ChangeLog
index 375d694..9b0cd18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@
* 1507 New optional parse_function for check API...
* 1445 quantum_libsmall_door, quantum_libsmall_status: Two new checks for monitoring
small Quantum tape libraries
* 1448 domino_info: check is extended to also show and monitor the
lnNotesServerState
+ * 1509 if, if64: New option for make inventory based on port alias...
* 1478 FIX: kernel.util, statgrab_cpu: fix computation of utilization...
* 1480 FIX: brocade_vdx_status: disable check on some devices that do not support
it...
* 1485 FIX: dell_om_disks, dell_om_esmlog, dell_om_mem, dell_om_processors,
dell_om_sensors: detect more devices...
diff --git a/checkman/if64 b/checkman/if64
index 036fb5e..2eb81b9 100644
--- a/checkman/if64
+++ b/checkman/if64
@@ -46,7 +46,7 @@ item:
inventory:
The inventory creates one service for each port that fulfills configurable conditions.
Per default these are ports which are currently found {up} and are of types {6}
(ethernetCsmacd),
- {32} (frameRelay) or {117} (gigabitEthernet).
+ {32} (frameRelay), {117} (gigabitEthernet) or several others.
{Grouping:} In some situations you do not want to monitor a single
interface but a group of interfaces that together form a pool.
diff --git a/checks/if.include b/checks/if.include
index f7f3c60..d5de510 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -116,6 +116,15 @@ def inventory_if_common(info, has_nodeinfo = False):
uses_alias = settings.get('use_alias', if_inventory_uses_alias)
porttypes = settings.get('porttypes', if_inventory_porttypes)
portstates = settings.get('portstates', if_inventory_portstates)
+ match_alias = settings.get('match_alias')
+
+ def alias_matches(alias):
+ if match_alias == None:
+ return True
+ for regex in match_alias:
+ if get_regex(regex).match(alias):
+ return True
+ return False
# Allow main check to set no port type (e.g. hitachi_hnas_fc_if)
porttypes.append("")
@@ -176,7 +185,7 @@ def inventory_if_common(info, has_nodeinfo = False):
duplicate.add(item)
seen_items.add(item)
- if ifType in porttypes and ifOperStatus in portstates:
+ if ifType in porttypes and ifOperStatus in portstates and
alias_matches(ifAlias):
params = {}
if if_inventory_monitor_state:
params["state"] = [ifOperStatus]
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 49ea1c4..46f5814 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -227,26 +227,41 @@ register_rule(group + '/' + subgroup_inventory,
title = _("Network Interface and Switch Port Inventory"),
valuespec = Dictionary(
elements = [
- ("use_desc", Checkbox(
+ ( "use_desc",
+ Checkbox(
title = _("Use description as service name for network interface
checks"),
label = _("use description"),
help = _("This option lets Check_MK use the interface description as
item instead "
"of the port number. If no description is available then
the port number is "
"used anyway."))),
- ("use_alias", Checkbox(
+ ( "use_alias",
+ Checkbox(
title = _("Use alias as service name for network interface
checks"),
label = _("use alias"),
help = _("This option lets Check_MK use the alias of the port
(ifAlias) as item instead "
"of the port number. If no alias is available then the
port number is used "
"anyway."))),
- ("portstates", ListChoice(title = _("Network interface port states
to inventorize"),
+ ( "match_alias",
+ ListOfStrings(
+ title = _("Match interface alias (regex)"),
+ help = _("Only inventorize interfaces whose alias matches one of the
configured "
+ "regular expressions. The match is done on the beginning of
the alias. "
+ "This allows you to select interfaces based on the alias
without having "
+ "the alias be part of the service description."),
+ orientation = "horizontal",
+ valuespec = RegExp(size = 32),
+ )),
+
+ ( "portstates",
+ ListChoice(title = _("Network interface port states to
inventorize"),
help = _("When doing inventory on switches or other devices with
network interfaces "
"then only ports found in one of the configured port states
will be added to the monitoring."),
choices = _if_portstate_choices,
toggle_all = True,
default_value = ['1'],
)),
- ("porttypes", ListChoice(title = _("Network interface port types
to inventorize"),
+ ( "porttypes",
+ ListChoice(title = _("Network interface port types to inventorize"),
help = _("When doing inventory on switches or other devices with
network interfaces "
"then only ports of the specified types will be created
services for."),
choices = _if_porttype_choices,
@@ -254,7 +269,8 @@ register_rule(group + '/' + subgroup_inventory,
toggle_all = True,
default_value = [ '6', '32', '62', '117',
'127', '128', '129', '180', '181', '182',
'205','229' ],
)),
- ("rmon", Checkbox(
+ ( "rmon",
+ Checkbox(
title = _("Collect RMON statistics data"),
help = _("If you enable this option, for every RMON capable switch
port an additional service will "
"be created which is always OK and collects RMON data. This
will give you detailed information "