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

0 comments

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
2.#top
3.#free
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.

Syntax:
#pmap pid-value


Example:
# pmap 1015
1015: cron
00110000 100K r-x-- /lib/libselinux.so.1
00129000 4K r---- /lib/libselinux.so.1
0012a000 4K rw--- /lib/libselinux.so.1
0012b000 36K r-x-- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
00134000 4K r---- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
00135000 4K rw--- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
00148000 4K r-x-- [ anon ]
00149000 1272K r-x-- /lib/tls/i686/cmov/libc-2.10.1.so
00287000 8K r---- /lib/tls/i686/cmov/libc-2.10.1.so
00289000 4K rw--- /lib/tls/i686/cmov/libc-2.10.1.so
0028a000 12K rw--- [ anon ]
002aa000 44K r-x-- /lib/libpam.so.0.82.1
002b5000 4K r---- /lib/libpam.so.0.82.1
002b6000 4K rw--- /lib/libpam.so.0.82.1
004af000 76K r-x-- /lib/tls/i686/cmov/libnsl-2.10.1.so
004c2000 4K r---- /lib/tls/i686/cmov/libnsl-2.10.1.so
004c3000 4K rw--- /lib/tls/i686/cmov/libnsl-2.10.1.so
004c4000 8K rw--- [ anon ]
004cf000 108K r-x-- /lib/ld-2.10.1.so
004ea000 4K r---- /lib/ld-2.10.1.so
004eb000 4K rw--- /lib/ld-2.10.1.so
00d0f000 8K r-x-- /lib/tls/i686/cmov/libdl-2.10.1.so
00d11000 4K r---- /lib/tls/i686/cmov/libdl-2.10.1.so
00d12000 4K rw--- /lib/tls/i686/cmov/libdl-2.10.1.so
00db5000 40K r-x-- /lib/tls/i686/cmov/libnss_files-2.10.1.so
00dbf000 4K r---- /lib/tls/i686/cmov/libnss_files-2.10.1.so
00dc0000 4K rw--- /lib/tls/i686/cmov/libnss_files-2.10.1.so
00e7e000 24K r-x-- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
00e84000 4K r---- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
00e85000 4K rw--- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
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
1.
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