Return value of current watt consumption on command line

On my system I can obtain the power drawn from the battery from

cat /sys/class/power_supply/BAT0/power_now
9616000

On Thinkpads if the tp_smapi module is loaded, the file is

cat /sys/devices/platform/smapi/BAT0/power_now

The value seems to be in µW, though. You can convert it with any tool you're comfortable with, e.g. awk:

awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT0/power_now
9.616 W

In case you cannot find the location within the sysfs file system, you can search for it:

find /sys -type f -name power_now 2>/dev/null

Additionally, the package lm-sensors may be used to determine the system power usage on some machines:

# sensors power_meter-acpi-0
power_meter-acpi-0
Adapter: ACPI interface
power1:      339.00 W  (interval =   1.00 s)

My laptop has none of these (it also has no battery currently), but it does have a "powercap" device.
It seems this device is able to set restrictions on the user power.

And it (naturally) can read the power draw in order to enforce them.
The power draw can be found at the energy_uj file, i.e.:

cat /sys/class/powercap/*/energy_uj

It'll show the lecture (or lectures, if you have many powercap devices) in micro-Joules. This is actually a counter of the energy consumed, so you need to divide it by a time delta in order to get the power.

Is this the power drawn by my laptop, or just a part of it? I don't know.


On a laptop by reading the ACPI data from either procfs or sysfs. On my system the files are:

/proc/acpi/battery/BAT0/state
/sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT0/power_now

Note that the sysfs is heavily symlinked so there are many ways to reach the file. power_now is the file name you are looking for.