From 7f11033c6eb5a2fe7244f0b9d471685909c0ec89 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 26 Apr 2024 12:05:02 +0100 Subject: [processor] handle `msr` module loading via predicate The cpupower and turbostat applications are not installed by default on most environments, but where it is, it will load the `msr` module when running this commends. Adding the predicate will solve this. Closes: #3610 Related: #3624, SET-622 Signed-off-by: Arif Ali --- sos/report/plugins/processor.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sos/report/plugins/processor.py b/sos/report/plugins/processor.py index e8e1da48..0cc8aa7f 100644 --- a/sos/report/plugins/processor.py +++ b/sos/report/plugins/processor.py @@ -6,7 +6,8 @@ # # See the LICENSE file in the source distribution for further information. -from sos.report.plugins import Plugin, IndependentPlugin +from sos.report.plugins import Plugin, IndependentPlugin, SoSPredicate +from sos.policies.distros.ubuntu import UbuntuPolicy class Processor(Plugin, IndependentPlugin): @@ -18,6 +19,8 @@ class Processor(Plugin, IndependentPlugin): files = ('/proc/cpuinfo',) packages = ('cpufreq-utils', 'cpuid') + cpu_kmods = [] + def setup(self): cpupath = '/sys/devices/system/cpu' @@ -48,15 +51,24 @@ class Processor(Plugin, IndependentPlugin): self.add_cmd_output([ "lscpu", "lscpu -ae", - "cpupower frequency-info", - "cpupower info", - "cpupower idle-info", "cpufreq-info", "cpuid", "cpuid -r", - "turbostat --debug sleep 10" ], cmd_as_tag=True) + if (isinstance(self.policy, UbuntuPolicy) and + self.policy.dist_version() == 24.04): + self.cpu_kmods = ['msr'] + + cpupower_pred = SoSPredicate(self, kmods=self.cpu_kmods) + + self.add_cmd_output([ + "cpupower frequency-info", + "cpupower info", + "cpupower idle-info", + "turbostat --debug sleep 10", + ], cmd_as_tag=True, pred=cpupower_pred) + if '86' in self.policy.get_arch(): self.add_cmd_output("x86info -a") -- cgit