我用lm-sensors在我的系统上运行D1,因为当我看youtube视频时,我的系统一直在关闭
因此,我想知道,如果没有第三方软件,比如lm-sensors,怎么能手动找到风扇和cpu的温度呢?我只是不知道它们存放在哪里。
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 6
model name : AMD Athlon(tm) II X2 240e Processor
power management: ts ttp tm stc 100mhzsteps hwpstatex86_64
发布于 2018-07-25 01:42:21
听起来你想要的是/sys/class/hwmon和/sys/class/thermal。
这两种方法都提供了基于shell的对所需数据的简单访问( hwmon目录还将包括其他传感器类型)。在您的系统中,每个传感器接口都有一个目录(可能有多个传感器)。
不过,还有三件事要注意:
sensors命令也不会产生任何可执行的效果。事实上,定期读取上述目录中的文件可能会产生更大的效果。发布于 2018-07-24 22:34:43
这个答案是通过直接访问机器专用寄存器(MSR)对一些Intel处理器手动监控处理器温度的一种方法。
首先要注意的是,在这种情况下,从MSR读出的是相对于Tcc,极限温度,所以需要额外的计算来确定实际温度。
参考英特尔64和IA-32架构软件开发人员手册,或者在您的情况下相当于AMD。
在我的例子中,我希望在0x1B1,也就是IA32_PACKAGE_THERM_STATUS上使用MSR的第22-16位。我年长的i7-2600 K的Tcc是98度。
下面是一个手动监控温度(和CPU频率)的简单脚本:
#! /bin/dash
#
# temp_mon3 Smythies 2016.10.05
# a simplified version of temp_mon2,
# for monitoring temp.
# Note: it is on purpose that -a is not used.
# Also CPU0 frequency (1 is good enough, when all
# are loaded).
#
# temp_mon2 Smythies 2016.09.29
# Monitor Package temperatures.
# Use clock modulation to control temps.
# i.e. simulate the second to last level
# of defense.
# Use simple primatives.
# run as sudo
# hardcoded for my tcc of 98 degrees.
#
echo ... begin package temperature monitoring ...
#
# In case I forgot (which I often do)
modprobe msr
#
# first let the drastic effect of the sudo command decay
# Done later in temp_mon3.
#
# some stuff
COMMAND="rdmsr --bitfield 22:16 -u 0x1B1"
COMMAND2="cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq"
#
# then get on with it
while [ 1 ];do
sleep 4
TEMP_RAW=$(eval $COMMAND)
CPU0_FREQ=$(eval $COMMAND2)
TEMP_ACT=$((98-TEMP_RAW))
echo "$TEMP_ACT $CPU0_FREQ"
done下面是一些示例输出,其中我在一段时间后添加了一些CPU负载(温度从31到73度):
$ sudo ./temp_mon3
[sudo] password for doug:
... begin package temperature monitoring ...
31 1605275
31 1605154
32 1605164
30 1605148
31 1605176
51 3511279
54 3511278
55 3511279
57 3511283
58 3511279
60 3511278
61 3511284
63 3511279
64 3511280
64 3511280
66 3511280
67 3511278
68 3511280
68 3511281
69 3511278
71 3511280
70 3511281
71 3511281
71 3511280
72 3511276
72 3511277
73 3511283
73 3511279
^C发布于 2018-07-24 21:58:41
lm-传感器项目(因此也是sensors命令)使用lib传感器库;库和包如下:
我还建议安装开发人员包(包括手册页),这与LTS 18.04和LTS 20.04相同:
sudo apt install libsensors4-dev在以下方面找不到一些背景资料:
man libsensors
man sensors.conf顺便说一句,这是同一个库,它读取sys目录中看到的温度。
总之,传感器是一个很好的选择。从命令行观察温度可以很容易地通过
watch -n 1 sensors如果您打算编写一个程序,请查看libsensors手册man libsensors或使用您的/usr/share/doc/文档。在C程序中,您必须包括#include 头。它将使用sensors.conf文件/etc/senors3.conf和/或/etc/senors.conf。如果您使用此选项,还可以在/etc/sensors.d/中找到进一步的(用户)配置。
如果您认为缺少一些传感器,请查看/sys/class/thermal或链接的/sys/devices/virtual/thermal目录。
若要获取所有热区的温度,请使用以下命令
$ cat /sys/devices/virtual/thermal/thermal_zone?/temp
77000
66000
67000用miliCelcius (mC)测量温度,在上述情况下,用摄氏77.0,66.0,67.0°C测得温度。
观察持续使用的温度
watch -n 1 cat /sys/devices/virtual/thermal/thermal_zone?/temp在这个目录中,您还可以找到有关冷却(风扇)设备的信息,以及PID调节器是如何编程的。
此外,一些超温保护是基于编码固件/硬件的(这是一个好主意),其设置数据被放置在您的bios中。
如果您希望以°C而不是°mC来显示温度,请使用bash计算$((value / 1000 ))或awk进行此转换:
cat /sys/devices/virtual/thermal/thermal_zone?/temp | awk '{printf " %5.2f °C\n" , $1/1000}'https://askubuntu.com/questions/1059170
复制相似问题