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

用于检索linux中内置设备功耗数据的接口或API,linux,linux-device-driver,daemon,power-management,Linux,Linux Device Driver,Daemon,Power Management,我需要为linux系统编写一个电源、温度监控系统。它需要像powerTop那样显示一些或所有内置设备的功率统计数据。我已经搜索了很多,但仍然不知道。谁能给我一个指导。要测量温度,你可以用这个工具。 有关功耗,请参阅。这两种版本都应该适用于大多数发行版 您可以使用这些工具确定所需的值并在软件中显示它们 lm_传感器的输出示例: pc87366-isa-6620 Adapter: ISA adapter VCORE: +2.01 V (min = +1.90 V, max = +2

我需要为linux系统编写一个电源、温度监控系统。它需要像powerTop那样显示一些或所有内置设备的功率统计数据。我已经搜索了很多,但仍然不知道。谁能给我一个指导。

要测量温度,你可以用这个工具。 有关功耗,请参阅。这两种版本都应该适用于大多数发行版

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

lm_传感器的输出示例:

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)
如果您没有获得某些值,则可能必须调整配置。查看以下位置(文本取自手册页):


如果你想完全自己写一些东西,你可以看看,哪些功能是通过提供的


应该让您首先查看导出的信息。

请提供有关该平台的更多详细信息。另请参阅。如果你有硬件,你可以测量电源电流和电压。如果你没有这个硬件,你必须猜。温度相同;所以,只有你给出一个关于硬件的线索,才能有人回答。它应该是任何Linux机器的通用。那么这是不可能的。你需要硬件支持。有些芯片与CPU的接口相同,但电源配置不同。也没有办法笼统地估计。如果有硬件支持,lmsensor和/sys/power将出现。我不明白lm_传感器为什么不提供电压读数?我刚刚更新了答案;确保对要读取的值有硬件支持。
/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.
ls /sys/power