Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need the best way to get the SUM of the total RAM usage for a given UID (Unix).

share|improve this question
    
Whatever technique you use, remember that some processes will be running as specific security contexts other than one of your users. For instance Apache will generally run as "nobody" or "www-data" or similar, including any CGI/PHP/other scripts unless you use something like suExec. Other server processes (such as mySQL) similarly will run as a single special user so not be counted against your human user's memory use. –  David Spillett Dec 23 '09 at 22:03

3 Answers 3

It will always be pretty inaccurate because of shared pages. However smem should be able to generate you such report.

share|improve this answer
    
smem looks good. I'd like to re-iterate that shared pages are big: e.g. on modern redhat systems, lots of things will mmap the locale database of about 90Mb, for tiny programs like each shell that runs. So adding up vmsize*processes will be misleading. –  pjc50 Jan 28 '10 at 16:08

As Michal says, this will be inaccurate due to shared pages, but if you wanted to you could build a script around a ps command

For example the couple of liner below would print out the virtual memory used by the UID 500 in KB:

#!/bin/bash
SUM=0
for MEM in `ps -u 500 -o vsize --no-headers`; do SUM=$((SUM+$MEM)); done
echo $SUM

Ewan

share|improve this answer

I believe atop can do per-user statistics.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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