Module: check_mk
Branch: master
Commit: 5014b78d95c42caac4bcacf3418da127a78e7256
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5014b78d95c42c…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Jan 27 15:02:31 2015 +0100
The connection speed of virtual interfaces is now determined correctly.
Per default, the highest speed of all physical interface members is taken.
Please note that this speed depends on how your virtual interfaces are configured.
It is also possible that a virtual interface has the accumulated bandwith of all its
physical
interfaces. In this case you need to set a "Assumed interface speed" in WATO.
Furthermore the check now outputs the physical interfaces for each virtual interface
and raises a warning if not all members have the same speed.
---
.werks/1928 | 18 ++++++++++
ChangeLog | 1 +
checkman/netapp_api_if | 3 ++
checks/netapp_api_if | 85 +++++++++++++++++++++++++++++++++++++++++-------
4 files changed, 95 insertions(+), 12 deletions(-)
diff --git a/.werks/1928 b/.werks/1928
new file mode 100644
index 0000000..d719eb0
--- /dev/null
+++ b/.werks/1928
@@ -0,0 +1,18 @@
+Title: netapp_api_if: Improved handling and check output of virtual interfaces
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1422367069
+Class: feature
+
+The connection speed of virtual interfaces is now determined correctly.
+Per default, the highest speed of all physical interface members is taken.
+
+Please note that this speed depends on how your virtual interfaces are configured.
+It is also possible that a virtual interface has the accumulated bandwith of all its
physical
+interfaces. In this case you need to set a "Assumed interface speed" in WATO.
+
+Furthermore the check now outputs the physical interfaces for each virtual interface
+and raises a warning if not all members have the same speed.
+
diff --git a/ChangeLog b/ChangeLog
index 4f16366..8037cce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,7 @@
* 1675 esx_vsphere_hostsystem.cpu_util_cluster: Averaged CPU utilization of all
cluster nodes...
* 1216 hp_procurve_cpu: Can now be configured with Wato
* 1676 if.include: now able to detect grouped interfaces...
+ * 1928 netapp_api_if: Improved handling and check output of virtual interfaces...
* 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/checkman/netapp_api_if b/checkman/netapp_api_if
index 0efcd7f..d1d29e4 100644
--- a/checkman/netapp_api_if
+++ b/checkman/netapp_api_if
@@ -9,6 +9,9 @@ description:
Right now only the ethernet and virtual interfaces are checked.
+ For virtual interfaces the check raises a WARN if not all members of
+ this virtual interface have the same speed set.
+
Depending on the check parameters this check can go WARN or CRIT when the
port status changes (i.e. is down), when the link speed changes (e.g. a
port expected to be set to 1GBit/s operates only at 100MBit/s), when the
diff --git a/checks/netapp_api_if b/checks/netapp_api_if
index 2a8e76b..c89582c 100644
--- a/checks/netapp_api_if
+++ b/checks/netapp_api_if
@@ -59,14 +59,9 @@ def netapp_convert_to_if64(info):
counter_key = "instance_name")
interfaces = parsed_data.get("net-ifconfig-get")
- nics = []
-
- for idx, entry in enumerate(sorted(interfaces)):
- nic_name, values = entry, interfaces[entry]
-
- # auto-1000t-fd-up
- speed = 0
- state = "1"
+ # Calculate speed, state and create mac-address list
+ if_mac_list = {}
+ for name, values in interfaces.items():
mediatype = values.get("mediatype")
if mediatype:
tokens = mediatype.split("-")
@@ -79,7 +74,51 @@ def netapp_convert_to_if64(info):
speed = 10000000000
elif "10" in mediatype:
speed = 10000000
- state = tokens[-1].lower() == "up" and "1" or
"2"
+ values["speed"] = speed
+ values["state"] = tokens[-1].lower() == "up" and
"1" or "2"
+ if "mac-address" in values:
+ if_mac_list.setdefault(values["mac-address"], [])
+ if_mac_list[values["mac-address"]].append(name)
+
+
+ nics = []
+ extra_info = {}
+ for idx, entry in enumerate(sorted(interfaces)):
+ nic_name, values = entry, interfaces[entry]
+
+ speed = values.get("speed", 0)
+ state = values.get("state", "2")
+
+ # Try to determine the speed and state for virtual interfaces
+ # We know all physical interfaces for this virtual device and use the highest
available
+ # speed as the virtual speed. Note: Depending on the configuration this behaviour
might
+ # differ, e.g. the speed of all interfaces might get accumulated..
+ # Additionally, we check if not all interfaces of the virtual group share the
same connection speed
+ max_speed = 0
+ min_speed = 0
+ if not speed:
+ if "mac-address" in values:
+ mac_list = if_mac_list[values["mac-address"]]
+ if len(mac_list) > 1: # check if this interface is grouped
+ extra_info.setdefault(nic_name, {})
+ extra_info[nic_name]["grouped_if"] = mac_list
+
+ for tmp_if in mac_list:
+ if tmp_if == nic_name:
+ continue
+ max_speed = max(max_speed,
interfaces[tmp_if].get("speed", 0))
+ min_speed = min(max_speed,
interfaces[tmp_if].get("speed", 0))
+ if max_speed != min_speed:
+ extra_info[nic_name]["speed_differs"] = True
+ speed = max_speed
+
+ # Virtual interfaces is "Up" if at least one physical interface is up
+ if "state" not in values:
+ if "mac-address" in values:
+ for tmp_if in if_mac_list[values["mac-address"]]:
+ if interfaces[tmp_if].get("state") == "1":
+ state = "1"
+ break
# Only add interfaces with counters
if "counters" in values:
@@ -115,14 +154,36 @@ def netapp_convert_to_if64(info):
nics.append(nic)
- return nics
+ return nics, extra_info
def inventory_netapp_api_if(parsed):
- for entry in parsed:
+ nics, extra_info = parsed
+ for entry in nics:
yield entry[1], None
+def check_netapp_api_if(item, params, parsed):
+ nics, extra_info = parsed
+ yield check_if_common(item, params, nics)
+
+ for line in nics:
+ ifIndex = line[0]
+ ifDescr = line[1]
+ ifAlias = line[18]
+ if type(ifIndex) == tuple:
+ ifGroup, ifIndex = ifIndex
+
+ ifDescr_cln = cleanup_if_strings(ifDescr)
+ ifAlias_cln = cleanup_if_strings(ifAlias)
+ if if_item_matches(item, ifIndex, ifAlias_cln, ifDescr_cln):
+ if ifDescr in extra_info:
+ vif_group = extra_info[ifDescr]
+ yield 0, "Physical interfaces: %s" %\
+ ", ".join([group for group in
vif_group["grouped_if"] if group != ifDescr])
+ if "speed_differs" in vif_group:
+ yield 1, "Interfaces do not have the same speed"
+
check_info["netapp_api_if"] = {
- 'check_function' : check_if_common,
+ 'check_function' : check_netapp_api_if,
'inventory_function' : inventory_netapp_api_if,
'parse_function' : netapp_convert_to_if64,
'service_description' : 'Interface %s',