Module: check_mk
Branch: master
Commit: cbb205f45d38916e75e6661cf749cd269b197c90
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cbb205f45d3891…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Oct 18 17:35:46 2016 +0200
3960 FIX if.include: fixed wrong order if interface groups are configured
---
.werks/3960 | 10 ++++++++++
ChangeLog | 1 +
checks/if.include | 47 +++++++++++++++++++++++++----------------------
3 files changed, 36 insertions(+), 22 deletions(-)
diff --git a/.werks/3960 b/.werks/3960
new file mode 100644
index 0000000..2217a88
--- /dev/null
+++ b/.werks/3960
@@ -0,0 +1,10 @@
+Title: if.include: fixed wrong order if interface groups are configured
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i2
+Date: 1476804826
+
+
diff --git a/ChangeLog b/ChangeLog
index 7fdf705..1ad77a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
* 3826 FIX: netapp_api_connection: now removes duplicate warning messages
* 3827 FIX: windows agent: fixed 3 bugs which broke the skype section
* 3650 FIX: Fixed bash versionitis, unbreaking cached check results....
+ * 3960 FIX: if.include: fixed wrong order if interface groups are configured
Multisite:
* 3959 Two new filters for the comment view: author and comment text field
diff --git a/checks/if.include b/checks/if.include
index 5751c22..4a866df 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -393,28 +393,26 @@ def check_if_common(item, params, info, has_nodeinfo = False,
group_name = "Grou
if params.get("aggregate"):
group_members = []
matching_interfaces = []
- node_offset = has_nodeinfo and 1 or 0
-
- def get_interface_item(line, what):
- ifIndex = line[ 0 + node_offset]
- if type(ifIndex) == tuple:
- ifGroup, ifIndex = ifIndex
-
- if what == "description":
- return line[ 1 + node_offset]
- elif what == "alias":
- return line[18 + node_offset]
- else: # index
- pad_portnumbers = item[0] == '0'
- return if_pad_with_zeroes(info, ifIndex, has_nodeinfo, pad_portnumbers)
for element in info:
- ifIndex = element[0 + node_offset]
+ node, line = if_extract_node(element, has_nodeinfo)
+ ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus, ifInOctets, \
+ inucast, inmcast, inbcast, ifInDiscards, ifInErrors, ifOutOctets, \
+ outucast, outmcast, outbcast, ifOutDiscards, ifOutErrors, \
+ ifOutQLen, ifAlias, ifPhysAddress = line
+
ifGroup = None
if type(ifIndex) == tuple:
ifGroup, ifIndex = ifIndex
- if_member_item = get_interface_item(element,
params.get("aggr_member_item"))
+ service_name_type = params.get("aggr_member_item")
+ if service_name_type == "description":
+ if_member_item = ifDescr
+ elif service_name_type == "alias":
+ if_member_item = ifAlias
+ else: # index
+ pad_portnumbers = item[0] == '0'
+ if_member_item = if_pad_with_zeroes(info, ifIndex, has_nodeinfo,
pad_portnumbers)
if ifGroup and ifGroup == item:
matching_interfaces.append((if_member_item, element))
@@ -425,7 +423,7 @@ def check_if_common(item, params, info, has_nodeinfo = False,
group_name = "Grou
# tryint -> force "01" and "1" to be identical.
if params.get("include_items") != None and
tryint(if_member_item) not in map(tryint, params["include_items"]):
add_interface = False
- elif params.get("iftype") != None and saveint(element[2 +
node_offset]) != params["iftype"]:
+ elif params.get("iftype") != None and saveint(ifType) !=
params["iftype"]:
add_interface = False
if add_interface:
matching_interfaces.append((if_member_item, element))
@@ -505,14 +503,19 @@ def check_if_common(item, params, info, has_nodeinfo = False,
group_name = "Grou
group_info["ifType"] = ifType # This is the fallback ifType if none
is set in the parameters
-
-
# Append an additional entry to the info table containing the calculated
group_info
num_up = 0
for (if_member_item, element) in matching_interfaces:
- if element[4] == '1' or (
- type(element[4]) == tuple and element[4][0] == '1'):
- num_up += 1
+ node, line = if_extract_node(element, has_nodeinfo)
+ ifIndex, ifDescr, ifType, ifSpeed, ifOperStatus, ifInOctets, \
+ inucast, inmcast, inbcast, ifInDiscards, ifInErrors, ifOutOctets, \
+ outucast, outmcast, outbcast, ifOutDiscards, ifOutErrors, \
+ ifOutQLen, ifAlias, ifPhysAddress = line
+
+ if ifOperStatus == '1' or (
+ type(ifOperStatus) == tuple and ifOperStatus == '1'):
+ num_up += 1
+
if num_up == len(matching_interfaces):
group_operStatus = "1" # up
elif num_up > 0: