betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

02 November 2005

Checking System Activity on Mac OS X on the Command Line

Logging into server, no GUI, see?

So I'm logging into a Mac OS X machine (Server or not) remotely by ssh to do some maintenance and check on the health of the system. What I might be interested in is how CPU, memory and disk usage is coping with the jobs the server has to do. If I was sitting in front of the machine I could open "Activity Monitor" and click my way through the GUI. Not an option for this machine, since there is no GUI level remote access. So what do I do? There are some command line tools to give me the information I need, let me show you top, vm_stat and iostat...

On my OpenBSD box "systat vmstat" is what I use for a full overview. That is not available for OS X, but some other tools are there. Most often used is "top", followed by "vm_stat" and "iostat".


"top" is well known and you likely have heard about it and probably used it before. The version on OS X is quite useable. After switching to "compatibility mode" (with 'x'), one can see only the processes of a single user (with 'U' and entering the user id or name). Top is good for checking what eats all the CPU time.


If it comes to memory usage, especially for the question "how much swap space am I using", then vm_stat can help. On Mac OS X that's vm_stat with an underscore, not vmstat. You just give vm_stat a delay in seconds (by calling it like "vm_stat 10" on the command line) and it updates the display repeatedly. Go on, try that out and then open a bunch of applications to see if pageouts are going up (which would mean that your machine has to page memory out on disk to make room for the new ones).

$ vm_stat 5
Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 58%)
  free active inac wire   faults     copy zerofill reactive  pageins pageout
 49314  97619 154001 26746 42361341   320895 24148787   145786    50308 3459
 49341  97814 153974 26551     2902       21     1429        0        0 0
 45297  98409 157246 26728    12056      805     5639        0      272 0
 40400 101288 158727 27265    14663      841     6746        0     1261 0
 36365 103524 160004 27787     8302      712     3519        0     1630 0
...looks like my workstation is OK, even with starting up Acrobat Reader and a bunch of smaller programs at once.


It took me longer to discover iostat. The man page says that "Iostat displays kernel I/O statistics on terminal, device and cpu operations." Which is quite a lot and probably more than I usually want. I just use it with a line like:

iostat -d -K -w 5
to show me only devices (-d), kilobytes instead of blocks (-K), and have a wait interval of 5 seconds (-w 5). Go ahead, try it and watch it while doing a find for "foobar" on your disks. As usual with all command line tools, read the fine man pages.
$ iostat -d -K -w 5
  KB/t tps  MB/s
 16.90   1  0.01
 31.79 131  4.07
 32.00 752 23.51
 32.00  35  1.10
  4.00   1  0.00
  0.00   0  0.00
Finding all files that start with "pimp" on my single disk got the activity up a bit, then I stopped it with control-C. The display shows me Kilobytes per transfer, transfers per second, and Megabytes per second. Interpretation is of course up to you not to the tool :-). Playing with the -I switch might be interesting.

Posted by betabug at 13:20 | Comments (0) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Zope Witch Experiences | Main | HelMUG Server Upgrade >>
There are no comments.
You can trackback to:
There are no trackbacks.