diff options
author | Arif Ali <arif.ali@canonical.com> | 2024-04-26 12:05:02 +0100 |
---|---|---|
committer | Jake Hunsaker <jacob.r.hunsaker@gmail.com> | 2024-04-26 15:23:16 -0400 |
commit | 7f11033c6eb5a2fe7244f0b9d471685909c0ec89 (patch) | |
tree | 51dfac03bef49c0f0ac25da9dbca4a561904c44d | |
parent | 9529386dc3691cbb78b4495317a120729cecac4a (diff) | |
download | sos-7f11033c6eb5a2fe7244f0b9d471685909c0ec89.tar.gz |
[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 <arif.ali@canonical.com>
-rw-r--r-- | sos/report/plugins/processor.py | 22 |
1 files 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") |