How To Find The RAM Utilization/Usage For A Service Or Server Or Process Or User?


This is a long time question in my mind. I used to try all sorts of commands to find what is the RAM utilization by a service. The commands are as follows.
1.#ps -ef
4.#cat /proc/meminfo

But none of these tools gives RAM utilization statistics for perticular user or service.

To serve this purpose there is a built in command in linux called pmap(process map). Let us have a look in to pmap usage.

#pmap pid-value

# pmap 1015
1015: cron
00110000 100K r-x-- /lib/
00129000 4K r---- /lib/
0012a000 4K rw--- /lib/
0012b000 36K r-x-- /lib/tls/i686/cmov/
00134000 4K r---- /lib/tls/i686/cmov/
00135000 4K rw--- /lib/tls/i686/cmov/
00148000 4K r-x-- [ anon ]
00149000 1272K r-x-- /lib/tls/i686/cmov/
00287000 8K r---- /lib/tls/i686/cmov/
00289000 4K rw--- /lib/tls/i686/cmov/
0028a000 12K rw--- [ anon ]
002aa000 44K r-x-- /lib/
002b5000 4K r---- /lib/
002b6000 4K rw--- /lib/
004af000 76K r-x-- /lib/tls/i686/cmov/
004c2000 4K r---- /lib/tls/i686/cmov/
004c3000 4K rw--- /lib/tls/i686/cmov/
004c4000 8K rw--- [ anon ]
004cf000 108K r-x-- /lib/
004ea000 4K r---- /lib/
004eb000 4K rw--- /lib/
00d0f000 8K r-x-- /lib/tls/i686/cmov/
00d11000 4K r---- /lib/tls/i686/cmov/
00d12000 4K rw--- /lib/tls/i686/cmov/
00db5000 40K r-x-- /lib/tls/i686/cmov/
00dbf000 4K r---- /lib/tls/i686/cmov/
00dc0000 4K rw--- /lib/tls/i686/cmov/
00e7e000 24K r-x-- /lib/tls/i686/cmov/
00e84000 4K r---- /lib/tls/i686/cmov/
00e85000 4K rw--- /lib/tls/i686/cmov/
08048000 32K r-x-- /usr/sbin/cron
08050000 4K r---- /usr/sbin/cron
08051000 4K rw--- /usr/sbin/cron
082e4000 132K rw--- [ anon ]
b784a000 8K rw--- [ anon ]
b7859000 16K rw--- [ anon ]
bfb47000 84K rw--- [ stack ]
total 2088K

When we see the output of this comand it will give details as follows
First column will show memory location
2.second column will show RAM utilization of each file opend by this process
3.Third column will show rw permission.
4.Last one will show what are the files opened by this process
5.And last line of this output will show total size used, here it is 2088K

Usage1 : To find how much RAM a process is taking
#pmap pid

Usage2 : To find how much RAM used by an application
#pmap `pgrep firefox'
Let me explain, `` quotes are used to submit a command which will allow to submit PID value for firefox.

Usage3 : To find how much RAM utilized by Mysql server
#pmap `pgrep mysqld` grep total

Usage4 : To find how much RAM used by a particular user
#pmap `ps -ef grep krishna awk '{print $2}'` grep total
Where krishna is user name.

Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page


    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here