-
-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
In linux.rs, the cpu_temp function (
systemstat/src/platform/linux.rs
Lines 723 to 734 in f884080
fn cpu_temp(&self) -> io::Result<f32> { | |
read_file("/sys/class/thermal/thermal_zone0/temp") | |
.or(read_file("/sys/class/hwmon/hwmon0/temp1_input")) | |
.and_then(|data| match data.trim().parse::<f32>() { | |
Ok(x) => Ok(x), | |
Err(_) => Err(io::Error::new( | |
io::ErrorKind::Other, | |
"Could not parse float", | |
)), | |
}) | |
.map(|num| num / 1000.0) | |
} |
A better approach is to scan through the hwmon hierarchy to find a temperature provided by a kernel module associated with a CPU. This is what CPU-X does:
https://github.com/TheTumultuousUnicornOfDarkness/CPU-X/blob/84f2da456e57898e5f6655794b2ff0712f41b8c9/src/util.cpp#L507-574
valpackett
Metadata
Metadata
Assignees
Labels
No labels