Powertop is a free and open source utility developed by Intel to monitor power consumption on Linux. The tool is able to display and export reports about the estimated discharge rate, and statics about processors and devices behavior. It also lets us easily tune some kernel parameters on the fly in order maximize battery life.
In this tutorial we see how to install Powertop on some of the most used Linux distributions, and how to use it to monitor power consumption.
In this tutorial you will learn:
- How to install Powertop on the most used Linux distributions
- How to use Powertop interactively
- How to implement suggested power saving features on the fly or automatically
- How to generate and export reports to CSV or HTML
|Category||Requirements, Conventions or Software Version Used|
|Other||Privileged access to your Linux system as root or via the
|Conventions||# – requires given linux-commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux-commands to be executed as a regular non-privileged user
Powertop is included in the official repositories of all the most used Linux distributions. To install the tool on Fedora, for example, we run:
$ sudo dnf install powertop
On Debian and Debian-based distributions, we can install the “powertop” package by using
$ sudo apt install powertop
Powertop is also packaged in the Archlinux “Extra” repository. We install it using
$ sudo pacman -S powertop
Before starting Powertop for the first time, it’s a good idea to calibrate it. In order to do so, when running on battery power, we launch the application with the
$ sudo powertop --calibrate
Calibration consists into cycling over various disk, display and USB states, retrieving and analyzing data. As part of the process, the display may be turned off, and other features, such as the internet connection, may be disabled. Just let the machine run as idle as possible, and wait for the calibration to finish. When it is over, Powertop will start in interactive mode.
The Powertop interface
Powertop interface is organized in tabs: we can use the TAB and Shift+TAB keys to switch tab (forward and backward, respectively), and arrow keys to move through the elements of the interface. Let’s take a look at the information displayed in each tab.
The “Overview” tab
In the “Overview” tab we can find information about the battery discharge rate, the estimated remaining time and the CPU usage. Below those information we can see the output is organized in four columns:
In the “Usage” column we can find the estimated usage of a resource, generically expressed in ms/s (milliseconds/second), µS (microseconds/second) or pkts/s (Packate rate – number of packets per second) for network interfaces. In the “Events/s” column, instead, we can see the wakeups generated by the resource. Here less is more: the less number of wakeup events, the less power consumption. In the third and fourth columns, “Category” and “Description”, we can see the type of resource (Device, Process, Timer, etc…) and a brief description of it.
The “Frequency stats” and “Idle stats” tabs
The “Frequency stats” and “Idle stats” tabs report information about the frequencies and the “C-states” (operating modes) the CPU is running at, respectively. The higher the C-state (and the time spent by a processor in it), the less power consumption.
The “Device stats” and “Tunables” tabs
In the “Device stats” tab we can find information similar to those reported in the overview but just for devices. The “Tunables” tab, instead, contains a series of power saving features suggested by Powertop and their respective state, either “Good” or “Bad”.
In order to toggle the state of a tunable we can simply select it and press “Enter”. The action performed under the hood is displayed in the interface. In the example below you can see I toggled “Autosuspend for USB device USB Receiver”. This made Powertop write “auto” to the
We can also apply all the settings at once, and without interaction, by launching Powertop with the
--auto-tune option. You will see those settings in “Good” state also if you install and use a power-saving tool like Tlp.
The “Wakeup” tab
Finally, in the “WakeUp” tab, we can manually toggle the “wake status” of each reported device manually (again, by selecting the appropriate entry and pressing “Enter”):
Powertop is able to generate static exportable reports, both in CSV or HTML format. To generate and export a report we invoke Powertop with the
-c (short for
-r (short for
--html) option, and (optionally) pass a filename as argument (by default reports are saved in a file named “powertop”, with the appropriate extension). To generate an HTML report, we run:
$ sudo powertop --html
Here is how the report looks like:
In this tutorial we learned how to install and use Powertop on some of the most used Linux distributions. The tool allow us to monitor and retrieve power usage statics and apply some suggested power saving tweaks. We took a tour of the Powertop interface, and we saw how to generate reports either in HTML or CSV format.