How to monitor CPU/RAM usage per-user?

Latest response

A little while ago I picked up a customer case where they were asking for a way to inspect cpu-usage & memory-usage from the perspective of each user, e.g., to figure out what percentage of CPU was user BOB using at any given moment. I whipped up the following KCS solution (and accompanying knowledge-base article) to answer their question and they were happy with it.

I know we rarely go looking for things when we don't have a need, so I just thought I'd share it with you power-users -- enjoy!


After some collaborative feedback from a colleague, I made some changes to this article that make it much more immediately usable. Two things to copy and paste and then you're off to the races with a workable script, showing output like the following:

[rsaw]$ utop
rsaw:   24.0% of total CPU,  68.7% of total MEM
root:   2.0% of total CPU,   4.0% of total MEM
lex:    1.1% of total CPU,   20.2% of total MEM
named:  0.6% of total CPU,   0.4% of total MEM