Module: check_mk
Branch: master
Commit: a9e53b52eeaa048810837e6e1a40b5599cc9cdf4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a9e53b52eeaa04…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Apr 15 14:25:15 2019 +0200
lnx_if: Fixed check and inventory plugin
Change-Id: I0e5aefc3d74c1187bd062b891080797463e9ffeb
---
checks/lnx_if | 23 ++++++++++++-----------
tests/unit/checks/test_lnx_if.py | 2 +-
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/checks/lnx_if b/checks/lnx_if
index d749232..a9b112a 100644
--- a/checks/lnx_if
+++ b/checks/lnx_if
@@ -144,16 +144,17 @@ def _parse_lnx_if_sections(info):
if iface is not None:
iface[line[0].strip()] = ":".join(line[1:]).strip()
- parsed = {}
- for k in set(ip_stats.keys()).union(ethtool_stats.keys()):
- iface = ip_stats.get(k, {})
- iface.update(ethtool_stats.get(k, {}))
- parsed[k] = iface
- return parsed
+ return ip_stats, ethtool_stats
def parse_lnx_if(info):
- nic_info = _parse_lnx_if_sections(info)
+ ip_stats, ethtool_stats = _parse_lnx_if_sections(info)
+
+ nic_info = {}
+ for k in set(ip_stats.keys()).union(ethtool_stats.keys()):
+ iface = ip_stats.get(k, {})
+ iface.update(ethtool_stats.get(k, {}))
+ nic_info[k] = iface
if_table = []
index = 0
@@ -239,19 +240,19 @@ def parse_lnx_if(info):
if_table.append(row)
- return if_table
+ return if_table, ip_stats
def inventory_lnx_if(parsed):
if linux_nic_check == "legacy":
return []
# Always exclude dockers veth* interfaces on docker nodes
- parsed = [e for e in parsed if not e[2].startswith("veth")]
- return inventory_if_common(parsed, has_nodeinfo=True)
+ if_table = [e for e in parsed[0] if not e[2].startswith("veth")]
+ return inventory_if_common(if_table, has_nodeinfo=True)
def check_lnx_if(item, params, parsed):
- return check_if_common(item, params, parsed, has_nodeinfo=True)
+ return check_if_common(item, params, parsed[0], has_nodeinfo=True)
check_info["lnx_if"] = {
diff --git a/tests/unit/checks/test_lnx_if.py b/tests/unit/checks/test_lnx_if.py
index be02eb2..b1293d5 100644
--- a/tests/unit/checks/test_lnx_if.py
+++ b/tests/unit/checks/test_lnx_if.py
@@ -33,7 +33,7 @@ def parsed_change(bandwidth_change):
str(6570143 + 4 * bandwidth_change), '55994', '0',
'0', '0', '0', '0', 'wlp2s0',
'd]\x86\xe4P/'
],
- ]
+ ], {}
DISCOVERY = [