linux系统电源管理之常用工具

目录

综述

TLP

tlp stat

采用新版本(V1.3.1)

upower

powertop

用新版本工具(V2.14)

可调整参数

CPU 频率信息

CPU IDLE信息

s-tui

​​​​​​​采用新版本(V1.1.1)

​​​​​​​Slimbook Battery


本系列用于记录linux电源管理一些资料收集及实验过程。

综述

TLP 用于调控笔记本各项参数,以达到节约电能的目的。主要注意采用新版本支持新硬件。

powertop 可以监控 系统的进程占用的cpu时间比、CPU的频率变化、idle时cpu的状态、总线及外设电源管理的配置、后台定时线程的唤醒时间等配置。此外可以针对以上信息进行调节。

Stress-Terminal UI, s-tui, monitors CPU temperature, frequency, power and utilization in a graphical way from the terminal.

目前以上几个工具 在CPU方面主要以intel为主,虽然powertop在宣称上支持ARM,但也需要arm厂商实际适配了内核的cpufreq cpuidle的驱动,将相关sys接口暴露出来才可以。

因为以上几个工具在使用时,要针对各个工具的配置项进行确认,最终整理输入一个工具支持的硬件集合列表。

TLP

工具主要依赖shell脚本实现。

https://www.cnblogs.com/ManWingloeng/p/12373806.html

https://github.com/d4nj1/TLPUI  图形调参

https://github.com/linrunner/TLP 源码 shell,可以研究设置了哪些。

https://linrunner.de/tlp/introduction   apt install tlp tlp-rdw

 

https://www.2daygeek.com/tlp-increase-optimize-linux-laptop-battery-life/    老外写的分项命令。

tlp stat

TLP配置

系统信息、启动参数、BIOS版本

CPU型号、CPU调频信息(和笔记本型号、CPU型号强相关

CPU温度及风扇信息 和笔记本型号、CPU型号强相关)

文件系统 中关于dirty的配置参数信息

磁盘的信息(smart,对于NVME盘的信息不能有效获取

AHCI 连接电源管理的策略信息(SCSI控制器)

AHCI Host控制器 Runtime 电源管理的策略配置信息

PCIE ASPM配置策略

无线接口(蓝牙、wifi、wwan)开关状态

audio设备电源管理策略

Runtime Power Management(各种外设power的始终开、还是自动调节)

USB设备电源管理

电池状态

 

采用新版本(V1.3.1)

make

make install 即可安装新版本

 ./tlp-stat -s

--- TLP 1.3.1 --------------------------------------------

 

+++ System Info

System         = IPASON  

BIOS           = 5.1。

 

upower

upower -d

 

Device: /org/freedesktop/UPower/devices/battery_BAT1

  native-path:          BAT1

  vendor:               Sunwoda-H

  model:                HB4692Z9ECW-41

  serial:               44901

  power supply:         yes

  updated:              2021年04月25日 星期日 11时14分32秒 (69 seconds ago)

  has history:          yes

  has statistics:       yes

  battery

    present:             yes

    rechargeable:        yes

    state:               discharging

    warning-level:       none

    energy:              48.3154 Wh

    energy-empty:        0 Wh

    energy-full:         56.0012 Wh

    energy-full-design:  55.2372 Wh

    energy-rate:         9.3208 W

    voltage:             16.398 V

    time to empty:       5.2 hours

    percentage:          86%

    capacity:            100%

    technology:          lithium-ion

    icon-name:          'battery-full-symbolic'

  History (rate):

1619320472 9.321 discharging

 

 

  

powertop

此是C /C++ 代码实现的工具

 sudo apt install powertop  (2.8版本 2015年)

 program to analyze power consumption on Intel-based laptops

https://zhuanlan.zhihu.com/p/57365414

https://www.w3cschool.cn/working_on_gnu_linux/working_on_gnu_linux-jugs27nu.html

powertop --html=report.html

https://www.2daygeek.com/powertop-monitors-laptop-battery-usage-linux/ 老外用的记

​​​​​​​、

用新版本工具(V2.14)

  • 安装包: sudo apt install libnl-genl-3-dev

在ARM上编译时还安装了如下两个包:

sudo apt install libncurses-dev

sudo apt install g++

  • 编译

./autogen.sh

./configure

usr/bin/ld: powertop-main.o: undefined reference to symbol 'pthread_join@@GLIBC_2.2.5'

/usr/bin/ld: //lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

修改powertop-2.14/src/Makefile: 由LDFLAGS = 修改为  LDFLAGS = -lpthread

make

src/powertop为编译生成的二进制。

新版本不止可以看到CPU Freq,其余几个tab的内容也更丰富准确  

可调整参数

CPU 频率信息

CPU IDLE信息

可以看出CPU 处于cX状态的占比。比如用stress -c 2 压测时,可以看到两个cpu 一直处于C0状态。其他C态,是intel cpu分别关闭cpu某些组件的状态描述。

 

 

​​​​​​​s-tui

sudo apt install python-pip stress  (2018年11月 0.8.3版本,最新版本是2021-02 V1.1.1

 

https://www.jianshu.com/p/16925fc6eaa1

 

实际测试,根据官网 https://github.com/amanusk/s-tui的命令sudo apt install s-tui 安装后才能正常使用命令s-tui

The tool was tested to run on X86 (Intel/AMD) as well as ARM systems. For example, s-tui can run on Raspberry-pi and other single board PCs

功能: Monitoring your CPU temperature/utilization/frequency/power

 

​​​​​​​采用新版本(V1.1.1)

pip install urwid

s-tui-1.1.1$ python -m s_tui.s_tui

 

​​​​​​​Slimbook Battery

https://launchpad.net/~slimbook/+archive/ubuntu/slimbook

https://ubuntuhandbook.org/index.php/2020/06/improve-battery-life-ubuntu-20-04-lts/

 

首先安装工具 add-apt-repository:

sudo apt-get install software-properities-common

sudo add-apt-repository ppa:slimbook/slimbook

sudo apt update

sudo apt install slimbookbattery

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

proware

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值