3

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    
HandleLidSwitch=hibernate
#HandleLidSwitchDocked=ignore

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 e.g.

  • 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?

  • 1
    You didn't mention how long it was before "When I next turn it on by opening the lid the battery is fully drained." I think it's about 48 hours for battery to drain on suspend but I'm not positive. When you hibernate there is no battery drain and the system resumes. There is hybrid-sleep where it suspends at first and then later hibernates. I think you should see answers in /var/log/syslog file but I haven't researched this one myself as I only suspend twice daily with power plugged in 24/7. – WinEunuuchs2Unix Sep 8 '17 at 2:57
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.