0

我需要为linux系统编写一个电源、温度监控系统。它需要为某些或所有内置设备显示一些电源统计信息,就像 powerTop 所做的那样。我已经搜索了很多,但我仍然一无所知。有人可以给我一个指导。

4

2 回答 2

1

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

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

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.
于 2013-04-28T15:49:23.887 回答
1

如果您想完全自己编写一些东西,您可以看看ACPI,它的功能是通过sysfs提供的。

ls /sys/power

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

于 2013-04-28T15:50:18.563 回答