简体   繁体   English

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

[英]Interface or API to retrieve power consumption data for built-in devices in linux

I need to write a power, temperature monitor system for linux system. 我需要为linux系统编写一个电源,温度监控系统。 It needs display some power statistics for for some or all builtin-devices as what powerTop does.I have searched quite a bit and I'm still clueless. 它需要显示一些或所有内置设备的功率统计数据,如powerTop所做的那样。我已经搜索了很多,我仍然无能为力。 Could some one give me a guidance. 有人可以给我一个指导。

For measuring the temperature you might use the lm_sensors tool. 要测量温度,可以使用lm_sensors工具。 For power consumption take a look at the acpi client . 有关功耗,请查看acpi客户端 Both should be available for most distributions. 两者都应该适用于大多数发行版。

You can use these tools to determine the required values and display them in your software. 您可以使用这些工具确定所需的值并在软件中显示它们。

Example output of lm_sensors: 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)

If you do not get certain values you might have to tweak your configuration. 如果您没有获得某些值,则可能需要调整配置。 Look at the following locations (text has been taken from the man page): 查看以下位置(文本已从手册页中获取):

 /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. 

If you want to write something completely on your own you may have a look at ACPI , which features are provided via sysfs . 如果你想完全自己写一些东西,你可以看看ACPI ,这些功能是通过sysfs提供的。

ls /sys/power

should give you a first look at the information exported. 应该先看看导出的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM