用于检索linux中内置设备的功耗数据的接口或API

时间:2013-04-28 15:34:25

标签: linux linux-device-driver daemon power-management

我需要为linux系统编写一个电源,温度监控系统。它需要显示一些或所有内置设备的功率统计数据,如powerTop所做的那样。我已经搜索了很多,我仍然无能为力。有人可以给我一个指导。

2 个答案:

答案 0 :(得分: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.

答案 1 :(得分:1)

如果您想完全自己写一些内容,可以查看ACPI,这些功能是通过sysfs提供的。

ls /sys/power

应该先看看导出的信息。