To get the system CPU temperature in Rust, we need to use a crate called sys-info
. This crate provides functions to retrieve system information, including CPU temperature.
First, add sys-info
to your Cargo.toml
file:
34 chars3 lines
Then, use the sys_info::loadavg()
function to retrieve the load average information, which includes the CPU temperature:
main.rs313 chars11 lines
Note that the get_temperature()
function returns the temperature in Celsius.
gistlibby LogSnag