‘powerstat’ is a simple and a lightweight tool (command-line based) that can be used to measure the power consumption of your GNU/Linux laptop computer. Other than the current power usage, it also outputs few other useful details (CPU idle, IRQ switches, ‘context switch rate’, etc) as well.
It was created by an Ubuntu developer, therefore, installing it in Ubuntu (including Debian based distributions) is pretty easy. However, if you use another distribution, such as Fedora, and also new to GNU/Linux, then installing ‘powerstat’ can be a bit difficult as there are no ‘RPM’ packages available.
But because ‘powerstat’ virtually has no dependencies (as they are already being met by the core OS utilities), you should be able to run it in almost any GNU/Linux distribution. Now ‘powerstat’ is not the only tool that one can use to measure power consumption as there are others (‘PowerTop’, ‘dstat‘ etc), but as mentioned above, I like it for its simplicity :).
‘A Universal method …’
Not only on Fedora (18, 17 etc), this method should also work in other GNU/Linux distributions according to my knowledge, though there can be occasions that it might fail to work (you never know 🙂 ).
Anyhow, by using the official ‘.deb’ packages available for Ubuntu and Debian, I have created a simple compressed package so we can easily install it in other distributions. So first download the compressed package from here.
Then double click on it and it will be opened by your archive manager. It only contains two file inside (called ‘powerstat’ & ‘powerstat.8.gz’), so extract them to your ‘Home’ folder (don’t extract to anywhere else).
Now open your Terminal window and enter the below commands (this will move the main executable file to your ‘/usr/bin’ folder thus letting you to execute it as an installed program, and the user manual to its proper location).
su -c 'mv powerstat /usr/bin'
su -c 'mv powerstat.8.gz /usr/share/man/man8'
This command however, might not work on certain distributions where the ‘root’ user account is disabled by default. So after entering it, if you cannot authorize it by using your user password (even if you have administrative privileges), then enter the below ones instead.
sudo mv powerstat /usr/bin
sudo mv powerstat.8.gz /usr/share/man/man8
That’s it, now it should be installed.
To run it, simply enter the below command (make sure to unplug the A/C adapter).
By default, ‘powerstat’ takes a long delay before running, about 300 seconds, (for allowing your computer to ‘idle’) but you can easily bypass that with the ‘-d’ argument as shown below.
powerstat -d 2
‘2‘ means that it will wait for 2 seconds before starting to measure the power consumption. So make sure to replace that value accordingly.
If you want to get a list of available commands, then use the below command.
Use the below one to read its full manual.
Well, that’s pretty much it. Good luck.