From 0eb9153e3d357824acd5e008e6c6e1290c9c2f66 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Tue, 3 Apr 2018 15:16:01 +0200 Subject: [PATCH] [infiniband] collect info from all active ports of all IB devices currently just the very first active port is checked Resolves: #1262 Signed-off-by: Pavel Moravec Signed-off-by: Bryn M. Reeves --- sos/plugins/infiniband.py | 46 +++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/sos/plugins/infiniband.py b/sos/plugins/infiniband.py index d70c567012..4484892f12 100644 --- a/sos/plugins/infiniband.py +++ b/sos/plugins/infiniband.py @@ -14,6 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import os from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin @@ -37,15 +38,52 @@ def setup(self): self.add_cmd_output([ "ibv_devices", - "ibv_devinfo", + "ibv_devinfo -v", "ibstat", - "ibstatus", + "ibstatus" + ]) + + # run below commands for every IB device and its active port + ports_cmds = [ "ibhosts", "iblinkinfo", "sminfo", "perfquery" - ]) + ] + IB_SYS_DIR = "/sys/class/infiniband/" + ibs = os.listdir(IB_SYS_DIR) + for ib in ibs: + """ + Skip OPA hardware, as infiniband-diags tools does not understand + OPA specific MAD sent by opa-fm. Intel provides OPA specific tools + for OPA fabric diagnose. + """ + if ib.startswith("hfi"): + continue + + for port in os.listdir(IB_SYS_DIR + ib + "/ports"): + # skip IWARP and RoCE devices + try: + p = open(IB_SYS_DIR + ib + "/ports/" + port + + "/link_layer") + except: + continue + link_layer = p.readline() + p.close() + if link_layer != "InfiniBand\n": + continue + + try: + s = open(IB_SYS_DIR + ib + "/ports/" + port + "/state") + except: + continue + state = s.readline() + s.close() + + if not state.endswith(": ACTIVE\n"): + continue - return + opts = "-C %s -P %s" % (ib, port) + self.add_cmd_output(["%s %s" % (c, opts) for c in port_cmds]) # vim: set et ts=4 sw=4 :