Module: check_mk
Branch: master
Commit: d51ddd84bb6bf0b2b2bd254d51a69305a3b4dec7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d51ddd84bb6bf0…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Feb 2 13:42:19 2015 +0100
#1220 if,if64: Discovery can now be based on port description
Like in Werk #1509 for ifAlias, interface checks can now also filter by ifDesc without the
need to use the ifdescription as part of the service description
---
.werks/1220 | 10 ++++++++++
ChangeLog | 1 +
checks/if.include | 12 +++++++-----
web/plugins/wato/check_parameters.py | 11 ++++++++++-
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/.werks/1220 b/.werks/1220
new file mode 100644
index 0000000..4bebc4c
--- /dev/null
+++ b/.werks/1220
@@ -0,0 +1,10 @@
+Title: if,if64: Discovery can now be based on port description
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1422880649
+Class: feature
+
+Like in Werk #1509 for ifAlias, interface checks can now also filter by ifDesc without
the need to use the ifdescription as part of the service description
+
diff --git a/ChangeLog b/ChangeLog
index 13071fe..6bace5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -68,6 +68,7 @@
* 1958 akcp_daisy_smoke: added new check for smoke sensors on expansion boards which
are daisy chained to an AKCP securityProbe 5E...
* 1219 synology_disks, synology_fans, synology_info, synology_raid, synology_status,
synology_update: Multiple Synology NAS Checks
* 1968 qlogic_fcport, qlogic_sanbox, qlogic_sanbox_fabric_element: Supporting SAN
Switch Module for IBM BladeCenter(R) now
+ * 1220 if,if64: Discovery can now be based on port description...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/if.include b/checks/if.include
index e6bd09f..d484ef9 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -131,12 +131,13 @@ def inventory_if_common(info, has_nodeinfo = False):
porttypes = settings.get('porttypes', if_inventory_porttypes)
portstates = settings.get('portstates', if_inventory_portstates)
match_alias = settings.get('match_alias')
+ match_desc = settings.get('match_desc')
- def alias_matches(alias):
- if match_alias == None:
+ def port_match(name, what):
+ if what == None:
return True
- for r in match_alias:
- if regex(r).match(alias):
+ for r in what:
+ if regex(r).match(name):
return True
return False
@@ -215,7 +216,8 @@ def inventory_if_common(info, has_nodeinfo = False):
duplicate.add(item)
seen_items.add(item)
- if ifType in porttypes and ifOperStatus in portstates and
alias_matches(ifAlias):
+ if ifType in porttypes and ifOperStatus in portstates and \
+ port_match(ifAlias, match_alias) and port_match(ifDescr, match_desc):
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 5af6329..59a564f 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -252,7 +252,16 @@ register_rule(group + '/' + subgroup_inventory,
orientation = "horizontal",
valuespec = RegExp(size = 32),
)),
-
+ ( "match_desc",
+ ListOfStrings(
+ title = _("Match interface description (regex)"),
+ help = _("Only discover interfaces whose the description matches one
of the configured "
+ "regular expressions. The match is done on the beginning of
the description. "
+ "This allows you to select interfaces based on the
description without having "
+ "the alias be part of the service description."),
+ orientation = "horizontal",
+ valuespec = RegExp(size = 32),
+ )),
( "portstates",
ListChoice(title = _("Network interface port states to discover"),
help = _("When doing discovery on switches or other devices with
network interfaces "