From b6e4591e83324670ffd03d5b1b0973acc70cc2f7 Mon Sep 17 00:00:00 2001 From: Alex Deiter Date: Fri, 22 Dec 2023 19:24:41 +0400 Subject: [PATCH] Fixed getNetData to work with all Linux distros Different Linux distributions are based on different versions of the iproute program. And different versions of iproute have a different output of the `ip -s link show` command. For example: RHEL 8.x, RHEL 9.x, Debian Linux 11.x, Ubuntu Linux 22.04, CentOS 9.x: eth0: mtu 1500 RX: bytes packets errors dropped missed mcast 24853310197 16845711 0 0 0 0 TX: bytes packets errors dropped carrier collsns 39899639748 979955 0 0 0 0 RHEL 7.x, SLES 12.x, Ubuntu Linux 18.04, Ubuntu Linux 20.04: eth0: mtu 1500 RX: bytes packets errors dropped overrun mcast 31158468129 1501879 0 0 0 0 TX: bytes packets errors dropped carrier collsns 40617993630 1183331 0 0 0 0 And we can parse both options missed and overrun. Signed-off-by: Alex Deiter --- nsdperfTool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsdperfTool.py b/nsdperfTool.py index e6e47d8..f6c66f4 100755 --- a/nsdperfTool.py +++ b/nsdperfTool.py @@ -280,7 +280,7 @@ def getNetData(allNodes): "\"nstat -az TcpRetransSegs\" output on node %s" % (node)) ipLinkInfo = chkcmd( "%s %s \"ip -s link show %s\"" % (ssh, node, netDev[node])) - ipLinkFormat = r"RX:\s*bytes\s*packets\s*errors\s*dropped\s*missed\s*mcast\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+TX:\s*bytes\s*packets\s*errors\s*dropped\s*carrier\s*collsns\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)" + ipLinkFormat = r"RX:\s*bytes\s*packets\s*errors\s*dropped\s*(?:missed|overrun)\s*mcast\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+TX:\s*bytes\s*packets\s*errors\s*dropped\s*carrier\s*collsns\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)" ipLink = re.search(ipLinkFormat, ipLinkInfo) if (not ipLink):