Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I've been asked to estimate the power consumption of the servers I run for my laboratory. I thought and I'd ask if there was some handy linux commandline to get the power consumption of the server. It looks like powertop is useful for minimizing power consumption but it does not seem to print that X server us using Y watts.

Is there something buried in the /proc system that would help me out?

share|improve this question

marked as duplicate by Anthon, Zelda, rahmu, slm, manatwork Jan 21 at 13:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Do you mean powertop shows no ACPI power usage estimate available? –  Mikel Apr 1 '11 at 3:00

5 Answers 5

up vote 5 down vote accepted

If your computer actually keeps track of power (e.g. notebook), than on kernel 3.8.11 you can use the command below. It returns power measured in miliwatts.

cat /sys/class/power_supply/BAT0/power_now

This works on kernel 3.8.11 (Ubuntu Quantal mainline generic).

share|improve this answer

Computers generally don't track the current they are drawing. It is common that there are voltage sensors that are readable.

Power consumption can vary widely over time depending on workload. CPUs now throttle back when load is low. Disks will shutdown when idle. Tools like powertop will track processes which trigger increases in power consumption. Other tools will aggressively tune down power consumption.

UPSs care about power consumption and often have accessible data.

The manufacturers specs will give you some idea of power consumption, but reconfiguration of hardware can change power consumption. This is probably a good place to start and estimate. Adding new devices or replacing existing ones may alter the power load.

There are devices like Kill-A-Watt that can be used to measure power consumption. However, they require disconnecting the device so that the power runs through the device.

You may want to invest in or borrow a current meter which works by clipping around the wire. This would allow you to calculate volt-amps. This is typically different (higher) than the wattage for servers.

share|improve this answer
    
It's also worth noting that UPSes care both about peak as well as sustained power draw. Peak load will happen during the initial phase of power-on when everything (particularly everything mechanical like fans and spinning platter drives) starts up, and whenever the system is working really hard for some reason. Sustained and average load will almost certainly be lower for many of the reasons you mention in your answer. –  Michael Kjörling Jun 6 '13 at 11:57
    
Startup load can be significantly above the running load. On a previous project we would blow the fuses in the breaker box during startup from a full shutdown. During normal usage our load was about 30% of the fuse rating. –  BillThor Jun 7 '13 at 0:23

I don't think most servers introspect their power consumption, at least not in a form that Linux can access. You might have better luck querying the servers' LOM modules (if any), but I usually get this kind of information from remote power strips.

share|improve this answer

freedektop's upower does the trick over dbus. My laptop need between 8 and 12 watts. Nice.

share|improve this answer

Another KISS solution completing Adam's sugestion. This is for people who dont have a power_now file. (Arch)

echo - | awk "{printf \"%.1f\", \
$(( \
  $(cat /sys/class/power_supply/BAT1/current_now) * \
  $(cat /sys/class/power_supply/BAT1/voltage_now) \
)) / 1000000000000 }"`

Reports the actual power draw in Watts with one decimal place.

share|improve this answer

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