Skip to content

Commit

Permalink
[networking] Add devlink commands from #1541
Browse files Browse the repository at this point in the history
This commit brings forward PR #1541, updated for the current design of
sos plugins, and ultimately adds several devlink commands for
collection.

Additionally included is some lingering fixups to f-strings.

Closes: #1541

Co-authored-by: Alexander Petrovskiy <[email protected]>
Co-authored-by: Jake Hunsaker <[email protected]>
Signed-off-by: Jake Hunsaker <[email protected]>
  • Loading branch information
TurboTurtle and kvadrage committed Aug 28, 2024
1 parent 08c9bc9 commit 34dda98
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions sos/report/plugins/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,35 @@ def setup(self):
"devlink dev param show",
"devlink dev info",
"devlink port show",
"devlink sb show",
"devlink sb pool show",
"devlink sb port pool show",
"devlink sb tc bind show",
"devlink -s -v trap show",
])

devlinks = self.collect_cmd_output("devlink dev")
if devlinks['status'] == 0:
devlinks_list = devlinks['output'].splitlines()
for devlink in devlinks_list:
self.add_cmd_output(f"devlink dev eswitch show {devlink}")
self.add_cmd_output([
f"devlink dev eswitch show {devlink}",
f"devlink sb occupancy snapshot {devlink}",
f"devlink sb occupancy show {devlink}",
f"devlink -v resource show {devlink}"
])
dev_tables = []
dpipe = self.collect_cmd_output(
f"devlink dpipe table show {devlink}"
)
if dpipe['status'] == 0:
for tableln in dpipe['output'].splitlines():
if tableln.startswith('name'):
dev_tables.append(tableln.split()[1])
self.add_cmd_output([
f"devlink dpipe table show {devlink} name {dname}"
for dname in dev_tables
])

# below commands require some kernel module(s) to be loaded
# run them only if the modules are loaded, or if explicitly requested
Expand Down Expand Up @@ -227,17 +249,17 @@ def collect_ss_ip_ethtool_info(self):
_subdir = f"namespaces/{namespace}"
ns_cmd_prefix = cmd_prefix + namespace + " "
self.add_cmd_output([
ns_cmd_prefix + "ip -d address show",
ns_cmd_prefix + "ip route show table all",
ns_cmd_prefix + "ip -s -s neigh show",
ns_cmd_prefix + "ip -4 rule list",
ns_cmd_prefix + "ip -6 rule list",
ns_cmd_prefix + "ip vrf show",
ns_cmd_prefix + "sysctl -a",
ns_cmd_prefix + f"netstat {self.ns_wide} -neopa",
ns_cmd_prefix + "netstat -s",
ns_cmd_prefix + f"netstat {self.ns_wide} -agn",
ns_cmd_prefix + "nstat -zas",
f"{ns_cmd_prefix} ip -d address show",
f"{ns_cmd_prefix} ip route show table all",
f"{ns_cmd_prefix} ip -s -s neigh show",
f"{ns_cmd_prefix} ip -4 rule list",
f"{ns_cmd_prefix} ip -6 rule list",
f"{ns_cmd_prefix} ip vrf show",
f"{ns_cmd_prefix} sysctl -a",
f"{ns_cmd_prefix} netstat {self.ns_wide} -neopa",
f"{ns_cmd_prefix} netstat -s",
f"{ns_cmd_prefix} netstat {self.ns_wide} -agn",
f"{ns_cmd_prefix} nstat -zas",
], priority=50, subdir=_subdir)
self.add_cmd_output([ns_cmd_prefix + "iptables-save"],
pred=iptables_with_nft,
Expand All @@ -260,10 +282,11 @@ def collect_ss_ip_ethtool_info(self):
# Devices that exist in a namespace use less ethtool
# parameters. Run this per namespace.
self.add_device_cmd([
ns_cmd_prefix + "ethtool %(dev)s",
ns_cmd_prefix + "ethtool -i %(dev)s",
ns_cmd_prefix + "ethtool -k %(dev)s",
ns_cmd_prefix + "ethtool -S %(dev)s"
f"{ns_cmd_prefix} ethtool %(dev)s",
f"{ns_cmd_prefix} ethtool -i %(dev)s",
f"{ns_cmd_prefix} ethtool -k %(dev)s",
f"{ns_cmd_prefix} ethtool -S %(dev)s",
f"{ns_cmd_prefix} ethtool -m %(dev)s"
], devices=_devs['ethernet'], priority=50, subdir=_subdir)

self.add_command_tags()
Expand Down

0 comments on commit 34dda98

Please sign in to comment.