无法获得cpu温度

时间:2018-01-27 03:41:18

标签: linux bash temperature

我当前的linux有问题,我试图通过bash获得温度的任何东西都不起作用。

我尝试过lm-sensors,我得到的只是gpu temp和cpu_fan(错误,总是说0 RPM) 在/ sys / class / thermal中,核心名为cooling_deviceX,其中没有热信息,只有电源和状态 最后,/ proc / acpi,没什么,juste wakeup

我不明白以前曾经工作过。但自从我上次重新安装以来,一切都没有。

我有一个Ryzen 7 1700,我使用自定义编译内核(4.9.76)运行mint 18.1,配置是从原始内核导入的。

这种情况出了什么问题?

编辑: 我找到了问题的原因,似乎缺乏对Ryzen的支持,仅适用于4.11及更高版本的内核。这解释了为什么它之前有效,因为我在主线4.15内核上。

2 个答案:

答案 0 :(得分:1)

这是我用来在Linux上获取CPU温度的脚本:

T=$(cat /sys/class/thermal/thermal_zone0/temp); echo $(( $T / 1000 ))°C

这对你有用吗?

此外,您可以尝试运行sudo sensors-detect

 $ sudo sensors-detect
[sudo] password for brian: 
# sensors-detect revision $Revision$
# System: LENOVO 2347G2U [ThinkPad T430] (laptop)
# Kernel: 4.14.11-1-ARCH x86_64
# Processor: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz (6/58/9)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): 

答案 1 :(得分:0)

以下是我多年来使用的内容:

_cputemp(){
  local T=`sensors|sed -E -n '/[0-9]:.*\+[0-9]+\.[0-9]°[CF]/!b;s:\.[0-9]*°[CF].*$::;s:^.*\+::;p'`
  local S=`echo "$T"|sed ':a;N;s:\n:\+:g;ba'`
  local C=`echo "$T"|wc -l`
  printf "%s°C\n" $((($S)/$C))
}

该函数运行sensors程序,然后获取所有温度的平均值。因此,严格来说,它不仅仅是CPU温度。