Module: check_mk
Branch: master
Commit: 8cef5c8d60037b0d3c704a2e402821aa8dcc1367
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8cef5c8d60037b…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jan 28 11:37:18 2015 +0100
check_cpu_peaks (doc/treasures/active_checks): Raises an alert if the CPU utilization does not exceed the given levels
---
doc/treasures/active_checks/check_cpu_peaks | 132 +++++++++++++++++++++++++++
1 file changed, 132 insertions(+)
diff --git a/doc/treasures/active_checks/check_cpu_peaks b/doc/treasures/active_checks/check_cpu_peaks
new file mode 100755
index 0000000..2dd344d
--- /dev/null
+++ b/doc/treasures/active_checks/check_cpu_peaks
@@ -0,0 +1,132 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+import sys, os, time, pprint, getopt
+
+# Note: This check only works in an OMD environment!
+sys.path.append(os.path.expanduser("~/share/check_mk/modules"))
+execfile(os.path.expanduser("~/etc/check_mk/defaults"), globals())
+execfile(os.path.expanduser("~/share/check_mk/modules/prediction.py"), globals())
+rrdcached_socket = None
+
+def usage():
+ sys.stderr.write("""== check_cpu_peaks ==
+This checks raises an alert if the CPU utilization over a configurable
+timeperiod (default is "-30 days until now") does NOT exceed the configured thresholds.
+It can be used to detect unchallenged hosts. The check is done by evaluating the
+rrd data of the given host and must therefore run in the same site where the rrd data
+of this host is located."
+
+USAGE: check_cpu_peaks [OPTIONS] HOST
+
+ARGUMENTS:
+ HOST Host
+
+OPTIONS:
+ -v Verbose mode, Outputs RRD data
+ -w Return WARN if this value (integer) is never breached in the check period
+ -c Return CRIT if this value (integer) is never breached in the check period
+ -u Until time (unixtimestamp)
+ -f From time (unixtimestamp), default is until time minus 30 days
+""")
+
+if len(sys.argv) < 2:
+ usage()
+ sys.exit(1)
+
+short_options = "vw:c:f:u:"
+opts, args = getopt.getopt(sys.argv[1:], short_options)
+
+opt_verbose = False
+host = None
+warn_level = None
+crit_level = None
+fromtime = None
+untiltime = None
+
+for o,a in opts:
+ if o in [ '-v' ]:
+ opt_verbose = True
+ elif o in [ '-w' ]:
+ warn_level = int(a)
+ elif o in [ '-c' ]:
+ crit_level = int(a)
+ elif o in [ '-f' ]:
+ fromtime = int(a)
+ elif o in [ '-u' ]:
+ untiltime = int(a)
+
+if len(args) == 1:
+ host = args[0]
+else:
+ usage()
+ sys.exit(2)
+
+if not untiltime:
+ untiltime = time.time()
+if not fromtime:
+ fromtime = untiltime - 86400 * 30
+
+try:
+ datasets = []
+ step_secs = 0
+ for key in ["system", "user", "wait"]:
+ data = get_rrd_data(host, "CPU utilization", key, "AVERAGE", fromtime, untiltime)
+ datasets.append(data[1])
+ util_total = map(lambda x: int(sum([y for y in x if y != None])),
+ zip(datasets[0], datasets[1], datasets[2]))
+
+ cpu_peak = max(util_total)
+ peak_time = time.localtime(fromtime + step_secs * util_total.index(cpu_peak))
+
+ if opt_verbose:
+ for idx, x in enumerate(datasets[0]):
+ sys.stdout.write("idx: %d " % idx)
+ sys.stdout.write("%s\t" % int(datasets[0][idx] or -1))
+ sys.stdout.write("%s\t" % int(datasets[1][idx] or -1))
+ sys.stdout.write("%s" % int(datasets[2][idx] or -1))
+ print ""
+
+ info = [ "CPU utilization (user, system, wait) from %s until %s" %\
+ (time.strftime("%b %d %H:%M:%S", time.localtime(fromtime)),
+ time.strftime("%b %d %H:%M:%S", time.localtime(untiltime))) ]
+
+ info.append("Highest Peak of %d%% at %s" % (cpu_peak, time.strftime("%b %d %H:%M:%S", peak_time)))
+ state = 0
+ if crit_level and cpu_peak <= crit_level:
+ info.append("less than %d (!!)" % crit_level)
+ state = 2
+ elif warn_level and cpu_peak <= warn_level:
+ info.append("less than %d (!)" % warn_level)
+ state = 1
+ print ", ".join(info)
+ sys.exit(state)
+except Exception, e:
+ # TODO: Exception handling could be improved.
+ # Right now no handling of MKGeneralException, etc. is implemented
+ print "Exception while processing data."
+ sys.exit(2)
+
Module: check_mk
Branch: master
Commit: 97e3d9cb101b71696f51e5ce275e768c8a403200
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=97e3d9cb101b71…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Tue Jan 27 21:48:33 2015 +0100
#1859 FIX cups_queues: linux agent now runs section cups_queues in cached mode
After reports of problems with the agent run time for printer servers with
very long print queues the agent now runs the cups_queues section in cached
mode with a cache time of 5 mins. This means that the section is updated
only every 5 mins.
---
.werks/1859 | 12 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 52 ++++++++++++++++++++++++-------------------
3 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/.werks/1859 b/.werks/1859
new file mode 100644
index 0000000..3e1aa52
--- /dev/null
+++ b/.werks/1859
@@ -0,0 +1,12 @@
+Title: cups_queues: linux agent now runs section cups_queues in cached mode
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1422391502
+Class: fix
+
+After reports of problems with the agent run time for printer servers with
+very long print queues the agent now runs the cups_queues section in cached
+mode with a cache time of 5 mins. This means that the section is updated
+only every 5 mins.
diff --git a/ChangeLog b/ChangeLog
index ff04e32..104713f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -106,6 +106,7 @@
* 1858 FIX: docsis_channels_downstream: allow for negative values of power in dBm
* 1847 FIX: oracle_logswitches: Fixed description of WATO rule for levels...
* 1877 FIX: printer_input/printer_output: Check can now handle non reported capacity unit
+ * 1859 FIX: cups_queues: linux agent now runs section cups_queues in cached mode...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request, added mailto link for error report...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 4d8fc0f..6a35472 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -418,30 +418,36 @@ fi
# Status of CUPS printer queues
if type lpstat > /dev/null 2>&1; then
if pgrep cups > /dev/null 2>&1; then
- echo '<<<cups_queues>>>'
- CPRINTCONF=/etc/cups/printers.conf
- if [ -r "$CPRINTCONF" ] ; then
- LOCAL_PRINTERS=$(grep -E "<(Default)?Printer .*>" $CPRINTCONF | awk '{print $2}' | sed -e 's/>//')
- lpstat -p | while read LINE
- do
- PRINTER=$(echo $LINE | awk '{print $2}')
- if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
- echo $LINE
+ # first define a function to check cups
+ function cups_queues () {
+ CPRINTCONF=/etc/cups/printers.conf
+ if [ -r "$CPRINTCONF" ] ; then
+ LOCAL_PRINTERS=$(grep -E "<(Default)?Printer .*>" $CPRINTCONF | awk '{print $2}' | sed -e 's/>//')
+ lpstat -p | while read LINE
+ do
+ PRINTER=$(echo $LINE | awk '{print $2}')
+ if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
+ echo $LINE
+ fi
+ done
+ echo '---'
+ lpstat -o | while read LINE
+ do
+ PRINTER=${LINE%%-*}
+ if echo $LOCAL_PRINTERS | grep -q $PRINTER; then
+ echo $LINE
+ fi
+ done
+ else
+ lpstat -p
+ echo '---'
+ lpstat -o | sort
fi
- done
- echo '---'
- lpstat -o | while read LINE
- do
- PRINTER=${LINE%%-*}
- if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
- echo $LINE
- fi
- done
- else
- lpstat -p
- echo '---'
- lpstat -o | sort
- fi
+ }
+ # Make cups_queues available for subshell
+ export -f cups_queues
+ # Use cups_queues function with run_cached and cache time of 5 mins
+ run_cached -s cups_queues 300 "cups_queues"
fi
fi
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',
Module: check_mk
Branch: master
Commit: d753a4ee8b978019bc41cc9caf432f91dea4750f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d753a4ee8b9780…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Jan 27 14:54:10 2015 +0100
fixed Changelog
---
ChangeLog | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 550b6b1..4f16366 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,11 +56,8 @@
* 1918 ps: new option for checking the age of a process (on Linux)...
* 1920 df: Linux filesystem check now supports displaying data reserved for root...
* 1675 esx_vsphere_hostsystem.cpu_util_cluster: Averaged CPU utilization of all cluster nodes...
-<<<<<<< HEAD
- * 1676 if.include: now able to detect grouped interfaces...
-=======
* 1216 hp_procurve_cpu: Can now be configured with Wato
->>>>>>> f5fb499eeb6b0891ec864d947d46b96789422c47
+ * 1676 if.include: now able to detect grouped 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...
Module: check_mk
Branch: master
Commit: fc1823292f223d6570bb9537059862a816d6488d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fc1823292f223d…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Jan 27 14:52:55 2015 +0100
#1676 if.include: now able to detect grouped interfaces
This feature is more developer oriented. There are no changes to any interface checks.
The inventory function in if.include can now automatically create interface groups.
If an interface is in a group you can specify this group in the first field (ifIndex) of the line.
Instead of a simple index, you now put a tuple of (ifGroup, ifIndex).
The inventory function detects if there are multiple interfaces in the same group and creates
a virtual interface out of them. Grouped interfaces are no longer listed separately.
---
.werks/1676 | 16 +++++++++++++
ChangeLog | 1 +
checks/if.include | 65 ++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 71 insertions(+), 11 deletions(-)
diff --git a/.werks/1676 b/.werks/1676
new file mode 100644
index 0000000..51af91d
--- /dev/null
+++ b/.werks/1676
@@ -0,0 +1,16 @@
+Title: if.include: now able to detect grouped interfaces
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1422366130
+Class: feature
+
+This feature is more developer oriented. There are no changes to any interface checks.
+
+The inventory function in if.include can now automatically create interface groups.
+If an interface is in a group you can specify this group in the first field (ifIndex) of the line.
+Instead of a simple index, you now put a tuple of (ifGroup, ifIndex).
+
+The inventory function detects if there are multiple interfaces in the same group and creates
+a virtual interface out of them. Grouped interfaces are no longer listed separately.
diff --git a/ChangeLog b/ChangeLog
index c6688c5..88a49f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,7 @@
* 1918 ps: new option for checking the age of a process (on Linux)...
* 1920 df: Linux filesystem check now supports displaying data reserved for root...
* 1675 esx_vsphere_hostsystem.cpu_util_cluster: Averaged CPU utilization of all cluster nodes...
+ * 1676 if.include: now able to detect grouped 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/checks/if.include b/checks/if.include
index e460b0f..e6bd09f 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -88,6 +88,14 @@ def if_extract_node(line, has_nodeinfo):
else:
return None, line
+def if_item_matches(item, ifIndex, ifAlias, ifDescr):
+ return item.lstrip("0") == ifIndex \
+ or (item == "0" * len(item) and saveint(ifIndex) == 0) \
+ or item == ifAlias \
+ or item == ifDescr \
+ or item == "%s %s" % (ifAlias, ifIndex) \
+ or item == "%s %s" % (ifDescr, ifIndex)
+
# Pads port numbers with zeroes, so that items
# nicely sort alphabetically
def if_pad_with_zeroes(info, ifIndex, has_nodeinfo):
@@ -96,7 +104,13 @@ def if_pad_with_zeroes(info, ifIndex, has_nodeinfo):
else:
index = 0
if if_inventory_pad_portnumbers:
- max_index = max([int(line[index]) for line in info])
+ def get_index(line):
+ if type(line[index]) == tuple:
+ return line[index][1]
+ else:
+ return line[index]
+
+ max_index = max([int(get_index(line)) for line in info])
digits = len(str(max_index))
return ("%0"+str(digits)+"d") % int(ifIndex)
else:
@@ -148,6 +162,11 @@ def inventory_if_common(info, has_nodeinfo = False):
inucast, inmcast, inbcast, ifInDiscards, ifInErrors, ifOutOctets, \
outucast, outmcast, outbcast, ifOutDiscards, ifOutErrors, \
ifOutQLen, ifAlias, ifPhysAddress = line
+
+ ifGroup = None
+ if type(ifIndex) == tuple:
+ ifGroup, ifIndex = ifIndex
+
ifDescr = cleanup_if_strings(ifDescr)
ifAlias = cleanup_if_strings(ifAlias)
@@ -182,6 +201,14 @@ def inventory_if_common(info, has_nodeinfo = False):
if pattern.get("single"):
is_only_in_group = True
+ # The agent output already set this interface to grouped
+ if ifGroup:
+ have_groups.setdefault(ifGroup, {"interfaces": [],
+ "iftype": ifType,
+ "include_items": []})
+ have_groups[ifGroup]["interfaces"].append((saveint(ifSpeed), ifOperStatus, ifType))
+ is_only_in_group = True
+
# Prepare single interfaces
if not is_only_in_group:
if item in seen_items: # duplicate
@@ -240,6 +267,9 @@ def check_if_common(item, params, info, has_nodeinfo = False):
node_offset = has_nodeinfo and 1 or 0
def get_interface_item(line):
ifIndex = line[ 0 + node_offset]
+ if type(ifIndex) == tuple:
+ ifGroup, ifIndex = ifIndex
+
ifDescr = line[ 1 + node_offset]
ifAlias = line[18 + node_offset]
if if_inventory_uses_description and ifDescr:
@@ -250,11 +280,21 @@ def check_if_common(item, params, info, has_nodeinfo = False):
if_item = if_pad_with_zeroes(info, ifIndex, has_nodeinfo)
return if_item
+
+
for element in info:
- match_item = not params.get("include_items") or (get_interface_item(element) in params["include_items"])
- match_type = not params.get("iftype") or (params["iftype"] == saveint(element[2 + node_offset]))
- if match_item and match_type:
+ ifIndex = element[0 + node_offset]
+ ifGroup = None
+ if type(ifIndex) == tuple:
+ ifGroup, ifIndex = ifIndex
+
+ if ifGroup and ifGroup == item:
matching_interfaces.append(element)
+ else:
+ match_item = not params.get("include_items") or (get_interface_item(element) in params["include_items"])
+ match_type = not params.get("iftype") or (params["iftype"] == saveint(element[2 + node_offset]))
+ if match_item and match_type:
+ matching_interfaces.append(element)
# Accumulate info over matching_interfaces
wrapped = False
@@ -273,6 +313,10 @@ def check_if_common(item, params, info, has_nodeinfo = False):
outucast, outmcast, outbcast, ifOutDiscards, ifOutErrors, \
ifOutQLen, ifAlias, ifPhysAddress = line
+ ifGroup = None
+ if type(ifIndex) == tuple:
+ ifGroup, ifIndex = ifIndex
+
if_item = get_interface_item(element)
perfdata = []
@@ -394,16 +438,15 @@ def check_if_common_single(item, params, info, force_counter_wrap = False, has_n
inucast, inmcast, inbcast, ifInDiscards, ifInErrors, ifOutOctets, \
outucast, outmcast, outbcast, ifOutDiscards, ifOutErrors, \
ifOutQLen, ifAlias, ifPhysAddress = line
+
+ ifGroup = None
+ if type(ifIndex) == tuple:
+ ifGroup, ifIndex = ifIndex
+
ifDescr = cleanup_if_strings(ifDescr)
ifAlias = cleanup_if_strings(ifAlias)
- if item.lstrip("0") == ifIndex \
- or (item == "0" * len(item) and saveint(ifIndex) == 0) \
- or item == ifAlias \
- or item == ifDescr \
- or item == "%s %s" % (ifAlias, ifIndex) \
- or item == "%s %s" % (ifDescr, ifIndex):
-
+ if if_item_matches(item, ifIndex, ifAlias, ifDescr):
# Display port number or alias in infotext if that is not part
# of the service description anyway
if item.lstrip("0") == ifIndex \