aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/plugins/__init__.py14
-rw-r--r--sos/policies/__init__.py6
2 files changed, 18 insertions, 2 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index a018472d..580c0941 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -128,6 +128,7 @@ class Plugin(object):
packages = ()
files = ()
commands = ()
+ kernel_mods = ()
archive = None
profiles = ()
sysroot = '/'
@@ -934,7 +935,7 @@ class Plugin(object):
overridden.
"""
# some files or packages have been specified for this package
- if any([self.files, self.packages, self.commands]):
+ if any([self.files, self.packages, self.commands, self.kernel_mods]):
if isinstance(self.files, six.string_types):
self.files = [self.files]
@@ -944,6 +945,9 @@ class Plugin(object):
if isinstance(self.commands, six.string_types):
self.commands = [self.commands]
+ if isinstance(self.kernel_mods, six.string_types):
+ self.kernel_mods = [self.kernel_mods]
+
if isinstance(self, SCLPlugin):
# save SCLs that match files or packages
type(self)._scls_matched = []
@@ -968,9 +972,15 @@ class Plugin(object):
return True
def _files_pkgs_or_cmds_present(self, files, packages, commands):
+ kernel_mods = self.policy.lsmod()
+
+ def have_kmod(kmod):
+ return kmod in kernel_mods
+
return (any(os.path.exists(fname) for fname in files) or
any(self.is_installed(pkg) for pkg in packages) or
- any(is_executable(cmd) for cmd in commands))
+ any(is_executable(cmd) for cmd in commands) or
+ any(have_kmod(kmod) for kmod in self.kernel_mods))
def default_enabled(self):
"""This decides whether a plugin should be automatically loaded or
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 5bdc7d85..9e2b719e 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -508,6 +508,12 @@ class LinuxPolicy(Policy):
def sanitize_case_id(self, case_id):
return re.sub(r"[^-a-z,A-Z.0-9]", "", case_id)
+ def lsmod(self):
+ """Return a list of kernel module names as strings.
+ """
+ lines = shell_out("lsmod", timeout=0).splitlines()
+ return [line.split()[0].strip() for line in lines]
+
def pre_work(self):
# this method will be called before the gathering begins