How to retrieve current wattage info on OS X?

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 3 do 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?


Solution 1:

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.

Solution 2:

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. :-)

Solution 3:

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.

Solution 4:

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.

You can find the software here : http://www.bresink.com/osx/HardwareMonitor.html

I'm not associated with this company at all, just found the tool to be very useful in my diagnostics arsenal.

Solution 5:

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".