Module: check_mk
Branch: master
Commit: d149a3616f612fcf1f509f684302b382f59bf1fc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d149a3616f612f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 5 14:54:54 2016 +0100
#3163 FIX Treat interface name '1' and '01' as identical when grouping
interfaces
Problem was that in the discovery rule for creating interface groups you had
to specify <tt>01</tt> as item (just it appeared in the service), while the
actual check compared agains the index (<tt>1</tt>). Both are treated
identical
now and in the rule you may specify either <tt>01</tt> or
<tt>1</tt>.
---
.werks/3163 | 12 ++++++++++++
ChangeLog | 1 +
checks/if.include | 7 ++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.werks/3163 b/.werks/3163
new file mode 100644
index 0000000..58b8d9e
--- /dev/null
+++ b/.werks/3163
@@ -0,0 +1,12 @@
+Title: Treat interface name '1' and '01' as identical when grouping
interfaces
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1454680372
+Class: fix
+
+Problem was that in the discovery rule for creating interface groups you had
+to specify <tt>01</tt> as item (just it appeared in the service), while the
+actual check compared agains the index (<tt>1</tt>). Both are treated
identical
+now and in the rule you may specify either <tt>01</tt> or
<tt>1</tt>.
diff --git a/ChangeLog b/ChangeLog
index 757213b..1a61316 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -253,6 +253,7 @@
* 3068 FIX: ps: added performance graphs for process handle count (windows only)
* 3069 FIX: unitrend_backup: fixed broken plugin output
* 2930 FIX: juniper_cpu_util: Better detection, find more devices...
+ * 3163 FIX: Treat interface name '1' and '01' as identical when
grouping interfaces...
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/checks/if.include b/checks/if.include
index d3bc4e1..9576910 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -286,7 +286,7 @@ def inventory_if_common(info, has_nodeinfo = False):
is_only_in_group = False
for group_name, pattern in group_patterns.items():
# Interfaces can be grouped by item and iftype
- match_item = not pattern.get("include_items") or (item in
pattern["include_items"])
+ match_item = not pattern.get("include_items") or (tryint(item) in
map(tryint, pattern["include_items"]))
match_type = not pattern.get("iftype") or
(pattern["iftype"] == saveint(ifType))
if match_item and match_type:
have_groups.setdefault(group_name, {"interfaces": [],
@@ -392,7 +392,8 @@ def check_if_common(item, params, info, has_nodeinfo = False,
group_name = "Grou
if ifGroup and ifGroup == item:
matching_interfaces.append((if_member_item, element))
- elif if_member_item in params.get("include_items", []) or\
+ # tryint -> force "01" and "1" to be identical.
+ elif (params.get("include_items") == None or tryint(if_member_item)
in map(tryint, params["include_items"])) or\
saveint(element[2 + node_offset]) == params.get("iftype"):
matching_interfaces.append((if_member_item, element))
@@ -488,7 +489,7 @@ def check_if_common(item, params, info, has_nodeinfo = False,
group_name = "Grou
if params.get("iftype"):
alias_info.append("iftype %s" % params["iftype"])
if params.get("include_items"):
- alias_info.append("grouped items")
+ alias_info.append("%d grouped interfaces" %
len(matching_interfaces))
if has_nodeinfo:
group_entry = [None]