2013-04-28 27 views
0

我需要为linux系统编写一个电源,温度监视器系统。它需要显示一些或所有内置设备的功耗统计信息,作为powerTop的功能。我已经搜索了很多,但我仍然无能为力。有人能给我一个指导吗?用于检索linux内置设备功耗数据的接口或API

+0

请详细介绍该平台。另请参阅[电源文档](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/power/00-INDEX)。如果您有*硬件*,则可以测量电源电流和电压。如果你没有这个硬件,你必须猜测。温度也一样;所以只有当你提供硬件线索时,有人可以回答。 – 2013-04-29 00:09:41

+0

它应该是任何Linux机器通用的。 – 2013-04-29 04:29:12

+0

然后这是不可能的。您需要硬件支持。一些芯片呈现与CPU相同的接口,但具有不同的功率分布。没有办法一般地估计。 *如果有硬件支持,lmsensor *和*/sys/power *将会出现。 – 2013-04-29 13:36:15

回答

1

要测量温度,您可以使用lm_sensors工具。 功耗看看acpi client。两者都应该适用于大多数发行版。

您可以使用这些工具来确定所需的值并将其显示在软件中。 lm_sensors的的

输出示例:

pc87366-isa-6620 
Adapter: ISA adapter 
VCORE:  +2.01 V (min = +1.90 V, max = +2.10 V) 
VCC:   +4.99 V (min = +0.00 V, max = +6.03 V) 
VPWR:  +11.88 V (min = +5.93 V, max = +28.02 V) 
+12V:  +11.93 V (min = +11.02 V, max = +13.01 V) 
-12V:  -12.19 V (min = -13.10 V, max = -11.06 V) 
GND:   +0.00 V (min = +0.00 V, max = +0.00 V) 
Vsb:   +3.28 V (min = +3.00 V, max = +3.59 V) 
Vdd:   +3.28 V (min = +3.00 V, max = +3.59 V) 
Vbat:  +3.01 V (min = +2.40 V, max = +3.01 V) 
AVdd:  +3.26 V (min = +3.00 V, max = +3.59 V) 
Temp:  +55.0°C (low = +0.0°C, high = +70.0°C) 
         (crit = +85.0°C) 

如果你没有得到你可能需要调整你的配置一定的值。请看下面的位置(文本已经从该名男子页拍摄):

/etc/sensors3.conf 
/etc/sensors.conf 
     The system-wide libsensors(3) configuration file. /etc/sensors3.conf is tried first, 
     and if it doesn't exist, /etc/sensors.conf is used instead. 

/etc/sensors.d 
     A directory where you can put additional libsensors configuration files. Files found 
     in this directory will be processed in alphabetical order after the default configura‐ 
     tion file. Files with names that start with a dot are ignored. 
+0

我不明白为什么lm_sensors没有给出电压读数? – 2013-05-07 12:27:06

+0

我刚更新了我的答案;确保你有你想读取的值的硬件支持。 – 2013-05-08 07:57:14

1

如果你想对自己的完全写的东西,你可以看看ACPI,它们通过提供功能sysfs

ls /sys/power 

应该先给你看看导出的信息。