aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/plugins/__init__.py13
-rw-r--r--sos/policies/__init__.py8
2 files changed, 8 insertions, 13 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 1a1464c1..b7a47b6a 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -1278,11 +1278,8 @@ class Plugin(object):
chdir=runat, binary=binary, env=env)
def is_module_loaded(self, module_name):
- """Return whether specified moudle as module_name is loaded or not"""
- if len(grep("^" + module_name + " ", "/proc/modules")) == 0:
- return False
- else:
- return True
+ """Return whether specified module as module_name is loaded or not"""
+ return module_name in self.policy.kernel_mods
# For adding output
def add_alert(self, alertstring):
@@ -1541,15 +1538,11 @@ class Plugin(object):
return True
def _check_plugin_triggers(self, files, packages, commands, services):
- 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) or
- any(have_kmod(kmod) for kmod in self.kernel_mods) or
+ any(self.is_module_loaded(mod) for mod in self.kernel_mods) or
any(self.is_service(svc) for svc in services))
def default_enabled(self):
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index a19daf22..f4aa3180 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -822,6 +822,7 @@ class LinuxPolicy(Policy):
def __init__(self, sysroot=None):
super(LinuxPolicy, self).__init__(sysroot=sysroot)
+ self.init_kernel_modules()
if self.init == 'systemd':
self.init_system = SystemdInit()
else:
@@ -874,11 +875,12 @@ class LinuxPolicy(Policy):
def sanitize_filename(self, name):
return re.sub(r"[^-a-z,A-Z.0-9]", "", name)
- def lsmod(self):
- """Return a list of kernel module names as strings.
+ def init_kernel_modules(self):
+ """Obtain a list of loaded kernel modules to reference later for plugin
+ enablement and SoSPredicate checks
"""
lines = shell_out("lsmod", timeout=0).splitlines()
- return [line.split()[0].strip() for line in lines]
+ self.kernel_mods = [line.split()[0].strip() for line in lines]
def pre_work(self):
# this method will be called before the gathering begins