Skip to content

fix: cpu temp now reads correctly on linux - #135

Closed
insberr wants to merge 2 commits into
valpackett:trunkfrom
insberr:trunk
Closed

insberr wants to merge 2 commits into
valpackett:trunkfrom
insberr:trunk

Conversation

@insberr

@insberr insberr commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

CPU temp (cpu_temp) is read from /sys/class/thermal/thermal_zone0/temp and falls back to /sys/class/hwmon/hwmon0/temp1_input, however the devices at hwmon can vary across systems/boots. For example, on my system hwmon0 is my nvme.

This is a simple fix that iterates over /sys/class/hwmon/ devices to find the k10temp or zenpower driver (whichever it finds first) which yield the tdie CPU temp.

Fixes #128

@valpackett

Copy link
Copy Markdown
Owner

Right, we need to do the same for the thermal zones as well tho! :D

Can you make the iteration function reusable for both? And cache the path after it's been found once, or even better, keep the file descriptor and reread from it on further invocations.

@insberr

insberr commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

It completely passed over me that /sys/class/thermal might need to be searched too, haha. Should be taken care of now! Also kept the file descriptor for future invocations.

Some additional testing might be required. My CPU temps are on hwmon so I cant really test thermal.

@valpackett

Copy link
Copy Markdown
Owner

Thanks!!

@valpackett valpackett closed this Sep 19, 2026
@insberr

insberr commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cpu_temp in Linux

2 participants