Is there a way to retrieve the current watt usage info on OS X Snow Leopard? I'm using mid-2010 iMac, so I'm not looking for just battery-related apps.

Does OS X even monitor power usage? Do I need to use an external reader between the power cord and the outlet?

I'm most interested in command-line/applescript based solutions for more convenient logging & stats, but I'm open for alternatives.

Both (@bmike's & @michaelmichael's) answers are undoubtedly correct. The meta–question in here was that is there any sensors/readers already on the PSU, that would work kind of like the way "kill-a-watt" works. I sense the answer for that is "no".

I know, it probably is just a wet dream, but a watt meter on board would be ideal for the computer to shout: "Look how eco-friendly I am; using just these watts!"

Ah!

@Kerri Shotts' suggested iStat Menus 3do get the wattage readings from some sensor, along with volt and amp stats. So the meters are there, but how I could access them programmatically?

Bounty! Will be given for solid command-line sensor reading solution or for recommending exceptionally good 3rd party software (like one with statistical and historical data tools at minimum).

Just to inform: the aforementioned iStat Menus 3 lists the following power related sensors:

Voltage Sensors (Volts)

AC/DC

AC/DC

AC/DC Shunt

CPU

CPU 1.8V S0

CPU CTT

Graphics Module

Memory

Current Sensors (Amps)

AC/DC

CPU

CPU VTT

Graphics Module

Power Sensors (Watts)

AC/DC

CPU

Graphics Module

It does state "sensors", but they might be calculated as @msanford commented. How can I get my hands on that data programmatically?

Macs are very eco friendly and the testing of a unit is done by Apple as well as labs with calibrated test rigs. Luckily we can use the settings to maximize the macs we have while they come up with more efficient models tomorrow.
–
bmike♦Jun 18 '11 at 1:00

1

Does the PSU not report its current load (as I'm fairly sure it reports its voltage)? If so, P = IV, or Watts = Current (in amperes) • Voltage (in volts). Wattage isn't something that's directly measured but calculated from current and voltage, so I wouldn't expect a sensor to report watts if there are already reports on voltage and current. If that helps…
–
msanfordJun 19 '11 at 18:02

@msanford it might help—if someone tells us how to read the readings from the PSU.
–
koiyuJun 20 '11 at 12:21

system_profiler SPPowerDataType seems to provide the most relevant information. On laptops it reports voltage and amperage which can give you the power consumption (mVolts × mAmperes × 10^-6 = Watts). It also reports Wattage, but that's actually a piece of metadata reported by Apple's power adapter, third-party power adapters can show blanks here. Since desktops do not have rechargeable batteries, there's no way to calculate power consumption by measuring charging and discharging of battery.

But wait, there's still hope! Apple publishes a lot of source code, and googling for Wattage or Power+mV hints that certain kernel extensions can be queried about power consumption. Unfortunately, I cannot come up with a working script right now, but it seems possible.

All of the data in iStat is just from keys in the ioregistry. You can pull a dump of it from the command line using ioreg:

ioreg -w 0 -l

That is going to be a lot of data to look through, you can carve it up in various ways. I do not believe the actual data you want is provided on iMac, the system monitors temperature in a number of places, but since it does not run on a battery it is less important to know the instantaneous current being pulled by the system, and thus probably not worth the cost of a sensor.

There is a paid application called Hardware Monitor that provides access to pretty much every sensor available on a mac including voltage, current and wattage which I believe you are looking for. It does include a command line utility to read this information.

I used this to track down a faulty logicboard in an iMac last year and found it worth the €7. It includes the ability to output the sensor values to a CSV which can be helpful for logging and visual display of the data. I'm not sure if it does PSU readings (as I don't have the app on the machine I'm on atm) but it hits pci, slots, cpu and lots of other.

Lyken wins the prize with this answer. What an amazing piece of software. Command line tool, menu bar, and full app. Unless the power supply itself is monitored in new macs, it won't give a total power rating, but this sure does a great job accessing all the data that is available.
–
bmike♦Jun 21 '11 at 20:34

Sorry for the late update, but, @Lyken, your +100 is well deserved: I hesitated on giving the full +200 as Hardware Monitor seemingly won't give the PSU wattage like iStat Menus 3 does; for some reason the HWM lists power sensors only for CPU A, 4 CPU High Sides and MXM Graphics Module. Great app nevertheless and I would had awarded your answer in a breeze if some other bounty answer would've met the automatic half-bounty-award rules. Like I said, +100 well deserved.
–
koiyuJun 29 '11 at 9:39

Yes, I do believe that HWM reads the sensors on a per model basis so it depends on what is available on your version. Did iStat Menu 3 read the PSU wattage on your model also?
–
DigitalchildJun 29 '11 at 23:55

The logic board measures temperature in several places to control the blowers and the CPU monitors temp to reduce clock rate when it becomes warmer than the blowers can cool it.

I suppose some PHD thesis might be done on integrating the fan speed and various temperature sensors to calculate an expected power consumption. It's possible to get a calculation and with some calibration, it might even be pretty accurate.

In reality since that data isn't exposed or recorded, you might have to measure externally. Decent home energy counters are between $150 and $300 w

You could rent or buy a unit that measures the power through the outlet and then run some test to see how much power the mac takes over an hour in certain conditions.

Off

Sleep

Idle

Various CPU loads

Maximum CPU, everything going

Then you could correlate these with CPU usage monitoring that is trivial over time using top and be able to add things up.

It all depends on what you really want to do with the data other than learn how the hardware works and have some cool graphs.

+ you need to add ad infinitum more things to the list. Probably by the time I'd had all conditions calibrated I would need to replace the current iMac :-D Maybe just some external basic W & kWh meters would do the trick, if there are no meters onboard.
–
koiyuJun 17 '11 at 18:24

1

:-) Glad you got the humor. My experience is that the macs draw 20 to 25% less than the specifications published by Apple even under rigorous tests to get everything drawing at max power.
–
bmike♦Jun 18 '11 at 0:58

@bmike I wouldn't be so sure about that, the rMBP is known to drain battery when sufficiently loaded on the CPU+GPU due to the 85W adapter providing insufficient current.
–
Steven LuJun 6 '13 at 3:41

@stevenlu I wouldn't be surprised if the latest 2013 era hardware pushes harder than the mid 2010 era tech that's being discussed here. Similarly, power management on 10.8 is more sophisticated than 10.6 was.
–
bmike♦Jun 6 '13 at 9:24

This doesn't satisfy the command-line requirements, but give a try to iStat Menus 3. It gives you readings on just about every sensor in your machine (which for me includes AC/DC Watts, CPU Watts, and GPU Watts). I'm sure it isn't 100% accurate, but it was more than accurate enough in tuning my machine to work within the limited constraints of my APC battery.

All that said, my machine is a 2010 iMac, so depending on your machine, it may or may not work. In addition, I don't see power readings specifically for the HDD (which should be minimal), or anything specific to the display (that said, reducing LCD brightness reduces the wattage quite a bit, so it is counted in total).

Worth a try at least. IIRC there is a free version, but it was so worth it that I went ahead and paid for it. I'm a bit of a control freak, so I have memory, temperature, disk activity, network activity, etc., in my menubar and love it. :-)

IANAEE (I am not an Electrical Engineer), but as I understand it's not possible to accurately measure a computer's power consumption via software. The best solution is to connect your Mac to a device like a Kill-a-Watt

If you're looking for a scriptable solution - and an interesting project - here are instructions on creating a wireless wattage monitoring system, or a "Tweet-a-Watt".