<< Go back to Posts
Warning : This document is still a draft

DRAFT - Linux Battery monitoring tools

This is my offline reminder about tools for checking battery state.



Main CLI Tools

  • powertop: This one is similar to htop, allowing monitoring in real time consumption / battery discharge
  • upower: Gives you battery information + battery “screenshot”
  • acpi (Advanced Configuration and Power Interface):
  • powerstat: Monitor your computer for a few minutes before returing
  • Battop

Usage

upower

uppower -e lists the different battery files.

For instance, I get:

/org/freedesktop/UPower/devices/line_power_AC0
/org/freedesktop/UPower/devices/battery_BAT0
/org/freedesktop/UPower/devices/DisplayDevice

Next, for each of these paths, I can request information about using uppower -i <path>

For instance, upower -i /org/freedesktop/UPower/devices/battery_BAT0 returns:

  native-path:          BAT0
  vendor:               ASUSTeK
  model:                ASUS Battery
  power supply:         yes
  updated:              mer. 21 févr. 2024 17:08:41 (13 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              39,364 Wh
    energy-empty:        0 Wh
    energy-full:         39,74 Wh
    energy-full-design:  45,6 Wh
    energy-rate:         2,405 W
    voltage:             11,4 V
    charge-cycles:       3
    time to full:        9,4 minutes
    percentage:          99%
    capacity:            87,1491%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1708531721	99,000	charging
  History (rate):
    1708531721	2,405	charging
native-path:          BAT0
vendor:               ASUSTeK
model:                ASUS Battery
power supply:         yes
updated:              mer. 21 févr. 2024 17:30:44 (79 seconds ago)
has history:          yes
has statistics:       yes
battery
  present:             yes
  rechargeable:        yes
  state:               discharging
  warning-level:       none
  energy:              36,879 Wh
  energy-empty:        0 Wh
  energy-full:         39,74 Wh
  energy-full-design:  45,6 Wh
  energy-rate:         7,204 W
  voltage:             11,4 V
  charge-cycles:       3
  time to empty:       5,1 hours
  percentage:          92%
  capacity:            87,1491%
  technology:          lithium-ion
  icon-name:          'battery-full-symbolic'
History (charge):
  1708533044	92,000	discharging
History (rate):
  1708533044	7,204	discharging
upower -i /org/freedesktop/UPower/devices/line_power_AC0
  native-path:          AC0
  power supply:         yes
  updated:              mer. 21 févr. 2024 15:38:41 (5470 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

Charging

And

upower -i /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              mer. 21 févr. 2024 17:08:41 (109 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               charging
    warning-level:       none
    energy:              39,364 Wh
    energy-full:         39,74 Wh
    energy-rate:         2,405 W
    charge-cycles:       N/A
    time to full:        9,4 minutes
    percentage:          99%
    icon-name:          'battery-full-charging-symbolic'

DisCharging:

power supply:         yes
updated:              mer. 21 févr. 2024 17:30:44 (3 seconds ago)
has history:          no
has statistics:       no
battery
  present:             yes
  state:               discharging
  warning-level:       none
  energy:              36,879 Wh
  energy-full:         39,74 Wh
  energy-rate:         7,204 W
  charge-cycles:       N/A
  time to empty:       5,1 hours
  percentage:          92%
  icon-name:          'battery-full-symbolic'

acpi

acpi -i

When Charging and almost full:

Battery 0: Charging, 99%, 00:07:54 until charged
Battery 0: design capacity 4000 mAh, last full capacity 3485 mAh = 87%

After disconnecting the charging cable:

Battery 0: Discharging, 99%, 04:24:54 remaining
Battery 0: design capacity 4000 mAh, last full capacity 3485 mAh = 87%

After a few minutes:

Battery 0: Discharging, 92%, 05:35:16 remaining
Battery 0: design capacity 4000 mAh, last full capacity 3485 mAh = 87%

To get more detailed information, acpi -V:

Battery 0: Discharging, 97%, 03:42:49 remaining
Battery 0: design capacity 4000 mAh, last full capacity 3485 mAh = 87%
Adapter 0: off-line
Thermal 0: ok, 53.0 degrees C
Thermal 0: trip point 0 switches to mode critical at temperature 103.0 degrees C
Cooling 0: Processor 0 of 0
Cooling 1: B0D4 no state information available
Cooling 2: intel_powerclamp no state information available
Cooling 3: x86_pkg_temp no state information available
Cooling 4: Processor 0 of 0
Cooling 5: INT3400 Thermal no state information available
Cooling 6: Processor 0 of 0
Cooling 7: pch_skylake no state information available
Cooling 8: iwlwifi 0 of 20
Cooling 9: iwlwifi_1 no state information available
Cooling 10: TCC Offset 2 of 63
Cooling 11: Processor 0 of 0
Cooling 12: SEN1 no state information available

As you can see, it is detailed but with many “no state information available” …

Powerstat

powerstat starts by collecting data during 300 seconds (5 minutes), and then gives you the power consumption every 10 seconds.

Running for 300.0 seconds (30 samples at 10.0 second intervals).
Power measurements will start in 180 seconds time.

  Time    User  Nice   Sys  Idle    IO  Run Ctxt/s  IRQ/s  Watts               
17:17:12  13.4   0.0   3.8  82.1   0.7    2  17849   3948   9.10
17:17:22  12.9   0.0   3.9  82.7   0.6    1  17374   4406  10.65
17:17:32  12.6   0.0   3.8  82.9   0.7    6  16996   4602  14.12
17:17:42  15.4   0.0   4.2  79.8   0.6    1  17205   4132   9.26
17:17:52  13.3   0.0   4.1  81.7   0.9    5  16830   4056   9.14
17:18:02  10.4   0.0   3.6  85.3   0.7    3  16052   4122   8.73
17:18:12   9.8   0.0   3.5  86.0   0.6    1  15430   4015  12.32
17:18:22  12.6   0.0   3.4  83.2   0.8    2  16753   5130  10.26
17:18:32  10.6   0.0   3.5  85.1   0.7    2  16682   5059  13.67
17:18:42  12.7   0.0   3.6  82.9   0.8    1  17281   4191   8.60
17:18:52  11.3   0.0   3.4  84.4   0.9    2  16684   4412   9.80
17:19:02  10.5   0.0   3.3  85.4   0.9    3  15623   3859   8.90
17:19:12   9.0   0.0   2.9  87.3   0.7    1  16077   4399  11.07
// after switching to battery saving mode
17:20:22  25.4   0.0   7.9  65.8   0.8    5  16308   4636   7.84
17:20:32  41.5   0.0  14.5  43.2   0.9    2  14624   5808   6.96
17:20:42  38.5   0.0  15.4  45.2   0.9    3  13987   5178   6.11
17:20:52  37.2   0.0  12.4  49.3   1.1    3  14182   4526   6.02
17:21:02  33.7   0.0  12.3  52.8   1.2    3  14147   4398   5.71
17:21:12  42.9   0.0  14.9  41.3   0.9    8  15152   6324   7.17
17:21:22  47.0   0.0  15.1  37.0   0.9    3  15216   6410   7.01
17:21:32  54.9   0.0  15.5  29.0   0.7    4  14925   6589   6.96
17:21:42  57.7   0.0  15.7  26.0   0.6    6  14820   7147   6.78
17:21:52  45.6   0.0  14.4  39.2   0.8    6  13934   4614   5.75
17:22:02  41.9   0.0  14.7  42.6   0.7    4  13771   4314   6.10

Pm-utils

sudo apt install pm-utils

Other tools here

Inxi

Easy to get battery life:

inxi -B gives current capacity over total. Let you know if you need to change your battery or not.



>> You can subscribe to my mailing list here for a monthly update. <<