Skip to content

Commit

Permalink
lscpu different in ubuntu 22.04, replace with psutil.cpu_freq
Browse files Browse the repository at this point in the history
  • Loading branch information
jhazentia committed Sep 27, 2024
1 parent be74889 commit 5a01af5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions scos_actions/hardware/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def get_current_cpu_clock_speed() -> float:
:return:
"""
try:
out = subprocess.run("lscpu | grep 'MHz'", shell=True, capture_output=True)
spd = str(out.stdout).split("\\n")[0].split()[2]
return float(spd)
cpu_freq = psutil.cpu_freq()
return cpu_freq.current
except Exception as e:
logger.error("Unable to retrieve current CPU speed")
raise e
Expand Down

0 comments on commit 5a01af5

Please sign in to comment.