Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to measure memory utilization of my Apache Server. Can I use the pmap command and pass all the process IDs of httpd and take that as total utilization?

pmap PID1 PID2 ....

It seems that pmap gives more info than just RAM utilization. Is there any command in Unix/Perl with which I can get the correct info for memory use?

share|improve this question
add comment

1 Answer

You can do this using the ps utility. The following will work in Linux:

ps -p $(pgrep -d',' -x apache2) -o rss= | awk '{ i += $1 } END { print "Usage: " i"K" }'

Replace apache2 with the process name your distro uses for apache.

share|improve this answer
    
Dose ps command gives the correct memory utilization or it's add some extra thing into calculation ? I have read in most of the blog that it add other thing too. –  Amit Nagar Dec 28 '12 at 8:32
    
It doesn't add anything. From the manpage: The SIZE and RSS fields don't count some parts of a process including the page tables, kernel stack, struct thread_info, and struct task_struct. This is usually at least 20 KiB of memory that is always resident. –  jordanm Dec 28 '12 at 17:20
4  
Be careful with those numbers, the RSS is the resident size, i.e., the pages of the process' address space that are currently in memory. Any shared pages (executable, shared constant data, shared COW modifiable data which hasn't been modified) will be added several times. The process SIZE is the size of the address space, which tells you even less how much memory it is using. –  vonbrand Jan 24 '13 at 16:53
add comment

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.