Ubuntu – How to Monitor My Laptop Battery Usage


My HP-745 G2 laptop is fully charged, I then unplug it and close the lid.

When I next turn it on (a day or two later) by opening the lid the battery is fully drained.

uname -a
Linux HP-745-G2 4.10.14-041014-generic #201705031501 SMP Wed May 3 19:03:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

grep HandleLid /etc/systemd/logind.conf    

There are various similar questions and suggestions on how to prevent this (although they don't seem to work for me).

However, what I am interested in is a way of monitoring the battery usage in some way

  • did it hibernate or not?
  • if not, what has prevented it?
  • which processes are draining the most battery

etc, etc

Is there anything like batterystats in android that can be analysed via the command line or an application?

Best Answer

To check if your laptop was hibernating, sleeping or active you can check the syslog files in the /var/log folder, for example with

grep -i 'shutdown\|sleeping\|hibernat\|resumed' /var/log/syslog*

AFAIK there isn't any software that keeps a history of battery usage of all processes, at least not something similar to what Android has. There are some statistics in the default 'Power statistics' application but it only shows how fast your battery was drained/charged, not which processes are responsible for it.

Probably the best you can do is install an application like PowerTOP (sudo apt install powertop). It shows which processes are most actively using the CPU. After PowerTOP has run on battery for some time and has taken enough measurements, it will start showing process power consumption in terms of wattage.

Powertop report screenshot

However I doubt if you can use it to check power consumption during hibernate or suspend. I tried generating a report with sudo powertop --html=powertop.html --time=300 while letting my laptop go into sleep mode and it seems the program just stops measuring while the system is sleeping. Also not all reported stats seem to be accurate when you use the --time= option and/or let your system go to sleep mode.

Related Question