27

The top command on OS X is pretty crappy.. The one included with most Linux distros allows you to change the sort-by column using < and >, there is a coloured mode (by pressing the z key), and a bunch of other useful options.

Is there a replacement command line tool? Ideally I would like htop for OS X, but because it relies on the /proc/ filesystem (see this thread) it has not been ported (and probably will never be)

The obvious answer is "Activity Monitor", but I'm looking for a command line tool!

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113
dbr
  • 1,538
  • 3
  • 16
  • 18
  • 3
    <3 htop. +1 added for this reason. Message extended because of the stupid character requirement. – Kent Fredric May 02 '09 at 13:52
  • ok, I've answered the 'sort' problem - what other "useful options" are you missing? – Alnitak May 02 '09 at 16:37
  • 3
    Note that a /proc filesystem *can* be made available using MacFUSE: http://osxbook.com/book/bonus/chapter11/procfs/ I don't know of any 'top' port that leverages this, however. – Sören Kuklau May 03 '09 at 18:54
  • 1
    I'm afraid that the MacFUSE procfs is not a drop-in replacement for Linux's procfs. When I tried compiling htop (or running dstat), I was stopped because there is no /proc/stat directory. – Clinton Blackmore Jun 02 '09 at 20:15

6 Answers6

23

top on MacOS X does support sorting, at least:

    O<skey>        Set secondary sort key to <skey> (see o<key>).
    o<key>         Set primary sort key to <key>: [+-]{command|cpu|pid
                   |prt|reg|rprvt|rshrd|rsize|th|time|uid|username|vprvt
                   |vsize}.
Alnitak
  • 20,901
  • 3
  • 48
  • 81
20

I'm working on porting htop to OSX. The repo is here (more active fork here, and can be installed via brew install htop)

I'm currently trying to work out what to do about the licensing clash between Apple's libtop (APSL) and htop (GPL). There's probably not much more programming to do on it - but I may have to re-implement the bits of libtop I need. If anyone has suggestions on how to make the licensing work please speak up.

enter image description here

Nakilon
  • 128
  • 1
  • 1
  • 8
hexten
  • 300
  • 2
  • 5
9

htop is now part of macports -- enjoy

Joel K
  • 5,765
  • 2
  • 29
  • 34
8

Glances - Eye on your system is what you are looking for. I previously used it on Linux, it is cross-platform and is really good.

Here is my screenshot.

enter image description here

chhantyal
  • 221
  • 2
  • 6
7

There is also a brew for htop if that's how you roll.

Unfortunately, Apple's /usr/bin/top continues to regress, as it no longer even understands compound single char args:

$ top -FR
invalid option or syntax: -FR
[...]

Now you must use e.g. "top -F -R -u". But, hey, Apple's "top" does not sort by cpu by default so perhaps that's the least of its worries.

Metaxis
  • 167
  • 1
  • 4
3

Top on OS X requires a little tweaking (it's not as 'blinged out' as GNU top), but it's easy to do.

On Leopard or Tiger, I use 'top -FRo [field]', where '[field]' is typically cpu, vsize, rsize, and so on. The -F and -R options will sacrifice some precision for memory calculation for a huge decrease in CPU usage by top.

Dan Udey
  • 1,460
  • 12
  • 17