加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

c – 使用AMD FX 4100四核在linux ubuntu 12.10上获得CPU温度

发布时间:2020-12-13 18:57:45 所属栏目:Linux 来源:网络整理
导读:有很多类似的问题,但我没有在那里找到解决方案. 如何在不调用传感器的情况下在Linux Ubuntu 12.10上获得C或C的CPU温度?我当然可以从文件中读取它,但是我找不到它在12.10中的存储位置.并且只是简单地阅读文本文件的可能性或者我可以使用系统调用或信号查询内

有很多类似的问题,但我没有在那里找到解决方案.

如何在不调用传感器的情况下在Linux Ubuntu 12.10上获得C或C的CPU温度?我当然可以从文件中读取它,但是我找不到它在12.10中的存储位置.并且只是简单地阅读文本文件的可能性或者我可以使用系统调用或信号查询内核吗?

我的文件夹/ p??roc / acpi /的内容就是

event  wakeup

没有THEMP0那里或类似的东西.然而,传感器应用可以在我的机器上显示温度.

no / sys / class / thermal / thermal_zone0 /目录

在/ sys / class / thermal我有

cooling_device0@  cooling_device1@  cooling_device2@  cooling_device3@

我正在尝试浏览lm-sensors源代码以寻找它如何检索温度,到目前为止无济于事,但我很接近.该文件是

http://lm-sensors.org/browser/lm-sensors/trunk/lib/sysfs.c

特别是:

第846行:

846 int sensors_read_sysfs_attr(const sensors_chip_name *name,847                             const sensors_subfeature *subfeature,848                             double *value)
最佳答案
根据sysfs documentation,传感器信息存储在/ sys / class / hwmon下,每个芯片有不同的目录.这与我在Ubuntu 13.10上看到的输出一致.

传感器使用的文件是:

/sys/class/hwmon/hwmon*/device/temp*

根据芯片/虚拟设备的数量,可以有许多hwmon目录.

我的双核系统输出:

$pwd
/sys/class/hwmon
$ls -l
total 0
lrwxrwxrwx 1 root root 0 May 17 14:29 hwmon0 -> ../../devices/virtual/hwmon/hwmon0
lrwxrwxrwx 1 root root 0 May 17 14:29 hwmon1 -> ../../devices/platform/coretemp.0/hwmon/hwmon1
lrwxrwxrwx 1 root root 0 May 17 14:29 hwmon2 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/hwmon/hwmon2

其中hwmon1是我的CPU的一个:

$pwd
/sys/class/hwmon/hwmon1/device
$ls -l
total 0
lrwxrwxrwx 1 root root    0 May 17 14:29 driver -> ../../../bus/platform/drivers/coretemp
drwxr-xr-x 3 root root    0 May 17 14:29 hwmon
-r--r--r-- 1 root root 4096 May 17 23:21 modalias
-r--r--r-- 1 root root 4096 May 17 14:29 name
drwxr-xr-x 2 root root    0 May 17 23:21 power
lrwxrwxrwx 1 root root    0 May 17 14:29 subsystem -> ../../../bus/platform
-r--r--r-- 1 root root 4096 May 17 14:29 temp2_crit
-r--r--r-- 1 root root 4096 May 17 14:29 temp2_crit_alarm
-r--r--r-- 1 root root 4096 May 17 14:29 temp2_input
-r--r--r-- 1 root root 4096 May 17 23:11 temp2_label
-r--r--r-- 1 root root 4096 May 17 14:29 temp2_max
-r--r--r-- 1 root root 4096 May 17 14:29 temp3_crit
-r--r--r-- 1 root root 4096 May 17 14:29 temp3_crit_alarm
-r--r--r-- 1 root root 4096 May 17 14:29 temp3_input
-r--r--r-- 1 root root 4096 May 17 23:11 temp3_label
-r--r--r-- 1 root root 4096 May 17 14:29 temp3_max
-rw-r--r-- 1 root root 4096 May 17 14:29 uevent

temp2 *和temp3 *的值分别对应于核心0和核心1.基本上这些是文件传感器从中读取数据.根据您的硬件设备,具有温度信息的CPU目录(在我的情况下为hwmon1)可能不同.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读