From dc75ed41c19249b14213f3bfeb26bcbd6503befb Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Tue, 20 Jun 2023 12:23:27 +0200 Subject: [PATCH] [conntrack] collect conntrack commands only when kmods are loaded Two conntrack commands require several kmods - guard collection of the commands by relevant SoSPredicate. Resolves: #3279 Signed-off-by: Pavel Moravec --- sos/report/plugins/conntrack.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sos/report/plugins/conntrack.py b/sos/report/plugins/conntrack.py index 608cc3355f..05068b5c8a 100644 --- a/sos/report/plugins/conntrack.py +++ b/sos/report/plugins/conntrack.py @@ -7,7 +7,8 @@ # # See the LICENSE file in the source distribution for further information. -from sos.report.plugins import Plugin, IndependentPlugin, PluginOpt +from sos.report.plugins import (Plugin, IndependentPlugin, SoSPredicate, + PluginOpt) class Conntrack(Plugin, IndependentPlugin): @@ -37,11 +38,18 @@ def setup(self): "conntrackd -s expect", ]) - # Collect info from conntrack + # Collect info from conntrack, only when all required kmods are loaded + ct_pred = SoSPredicate(self, + kmods=['nf_conntrack', + 'nf_conntrack_netlink', + 'nf_defrag_ipv4', + 'nf_defrag_ipv6', + 'nfnetlink'], + required={'kmods': 'all'}) self.add_cmd_output([ "conntrack -L -o extended", "conntrack -S", - ]) + ], pred=ct_pred) # Capture additional data from namespaces; each command is run # per-namespace