Is there a command I can use from the Terminal on OS X to get the usage percentage per CPU/core in numerical format on my dual-core iMac?

I'm going to need to grab this every 5/10 seconds so I'm looking for something "low-cost" - that isn't going to hit the CPU too hard. Maybe something like top, but which shows both CPU/cores, that I can parse and then display in GeekTool;

Core 1: 11%
Core 2: 7%
link|improve this question

44% accept rate
feedback

2 Answers

Top shows individual cores, you only have to press '1'. I think there's also an option to change the refresh rate.

link|improve this answer
1  
OS X's top doesn't have this nice Linux-y feature. – guns Sep 9 '09 at 22:35
didn't know that, I expected it to be a standard feature – bandi Sep 10 '09 at 10:42
feedback

There is a wonderful extension to top, called HTop, which shows real-time graphs per CPU in the top-left of the display, as well as many other controls and great customisability:

htop

There is a tutorial on how to get a HTop port built for OS X:

http://www.geektechnica.com/2009/07/how-to-install-htop-on-osx/

http://github.com/AndyA/htop-osx/tree/master

UPDATE:

htop from macports installs and works perfectly.

link|improve this answer
The title bar, it burns! – jtbandes Aug 23 '09 at 3:38
htop needs to be updated for Snow Leopard: trac.macports.org/ticket/21036 – hanleyp Sep 5 '09 at 2:50
feedback

Your Answer

 
or
required, but never shown

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