【发布时间】:2020-10-07 09:48:50
【问题描述】:
有很多类似的问题,但我还没有找到解决方案。
如何在 Linux Ubuntu 12.10 不调用 sensors 的情况下获取 C 或 C++ 中的 CPU 温度?我当然可以从文件中读取它,但是我找不到它在 12.10 中的存储位置。是否只有读取文本文件的可能性,或者我可以使用系统调用或信号查询内核?
我的文件夹 /proc/acpi/ 的内容只是
event wakeup
那里没有 THEMP0 或类似的东西。 sensors 应用程序可以在我的机器上显示温度。
没有/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)
【问题讨论】:
-
strace -f /usr/bin/sensors 2>&1 |grep open看看sensors打开了什么,可能会给你一个线索。
标签: c++ c linux cpu temperature