相关文章推荐


Centos系列

​1​

​yum ​ ​​ ​install​ ​​ ​lm_sensors​


​2​

​sensors-detect​


​3​

​sensors​

Ubuntu系列(多了service module-init-tools start一步骤)

​1​

​apt-get ​ ​​ ​install​ ​​ ​lm-sensors​


​2​

​sensors-detect​


​3​

​service module-init-tools start​


​4​

​sensors​

也可以通过sys系统读取cpu的温度: /sys/class/hwmon/hwmon0/device/


参考:http://www.mjmwired.net/kernel/Documentation/thermal/sysfs-api.txt


获取cpu温度

要获取cpu的温度可以通过汇编指令来读取,这里以intel cpu为例,用rdmsr指令读取IA32_THERM_STATUS_MSR(0x019C)的值,然后用TjunctionMax 减去这个值就是当前cpu的温度,对于一般的intel cpu 的TjunctionMax值是固定的,比如我的cpu是Intel Core 2 (45nm),在官网上可以查到其值是100摄氏度,到后面的intel cpu专门有个寄存器IA32_TEMPERATURE_TARGET(0x01A2)保存TjunctionMax的值,可以通过rdmsr指令读取。但是rdmsr指令只能在Ring0层运行,在运用层是执行 Read More

 
推荐文章