LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-05-2013, 06:26 PM   #1
forumbala88
LQ Newbie
 
Registered: Feb 2013
Posts: 8

Rep: Reputation: Disabled
Ram utilisation for a particular user


Hi friends

What command we have to use to find the ram utilisation for a particular user in linux

Regards
forumbala
 
Old 03-06-2013, 04:51 AM   #2
Rohit_4739
Member
 
Registered: Oct 2010
Distribution: Red Hat
Posts: 228

Rep: Reputation: 9
Quote:
Originally Posted by forumbala88 View Post
Hi friends

What command we have to use to find the ram utilisation for a particular user in linux

Regards
forumbala
Well the question is not correct as per my knowledge, because you look for RAM utilization per process and not per user. What you can do is you find all the processes running as a particlular user and then you can find memory/RAM utilization for all those process. There are multiple ways you can do that. YOu can use Top command to find the top processes consuming the memory (Virt and RES). If you want to know about a aprticular process use the pmap command like below

Code:
pmap <pid>
pmap 23305

Out put would be something like this.

23305:   java -Dmule.home=/mule/mule -Dmule.base=/mule/mule -Djava.net.preferIPv4Stack=TRUE -XX:MaxPermSize=256m -Djava.endorsed.dirs=/mule/mule/lib/endorsed -Docs.env=prod -Dmule.mmc.bind.port=1521 -Xms6144m -Xmx6144m -Djava.library.path=%LD_LIBRARY_PATH%:/mule/mule/lib/boot -classpath %MULE_LIB%:/mule/mule/conf:/mule/mule/lib/boot/commons-cli-1.2.jar:/mule/mule/lib/boot/commons-codec-1.3-osgi.jar:/mule/mule/lib/boot/jul-to-slf4j-1.6.1.jar:/mule/mule/lib/boot/licm-1.1.2.jar:/mule/mule/lib/boot/log4j-1.2.16.jar:/mu
0000000040000000     36K r-x--  /mule/jdk1.6.0_31/bin/java
0000000040108000      8K rwx--  /mule/jdk1.6.0_31/bin/java
000000004010a000     12K -----    [ anon ]
000000004010d000   1016K rwx--    [ anon ]
000000004020b000     12K -----    [ anon ]
000000004020e000   1016K rwx--    [ anon ]
000000004030c000     12K -----    [ anon ]
000000004030f000   1016K rwx--    [ anon ]
000000004040d000     12K -----    [ anon ]
0000000040410000   1016K rwx--    [ anon ]
000000004062d000     12K -----    [ anon ]
0000000040630000   1016K rwx--    [ anon ]
00000000407af000     12K -----    [ anon ]
00000000407b2000   1016K rwx--    [ anon ]
00000000408b0000     12K -----    [ anon ]
00000000408b3000   1016K rwx--    [ anon ]
00000000409b1000     12K -----    [ anon ]
00000000409b4000   1016K rwx--    [ anon ]
0000000040ab2000     12K -----    [ anon ]
0000000040ab5000   1016K rwx--    [ anon ]
0000000040bb3000     12K -----    [ anon ]
0000000040bb6000   1016K rwx--    [ anon ]
0000000040d3c000     12K -----    [ anon ]
0000000040d3f000   1016K rwx--    [ anon ]
..........
..........
00002ae6a6e67000   1748K rwx--  /mule/jdk1.6.0_31/jre/lib/amd64/server/libjvm.so
00002ae6a701c000    232K rwx--    [ anon ]
00007fff6ef45000     84K rwx--    [ stack ]
00007fff6effc000     16K r-x--    [ anon ]
ffffffffff600000   8192K -----    [ anon ]
 total          7684108K

Last line will show you the total memmory usage for the process.
You can also use the following code to find the 20 process using maximum RAM
Code:
for i in /proc/*/smaps ; do awk '/Rss/ {sum += $2}; END{if (sum>0) print FILENAME " Total: " sum/1024}' $i; done   |  sort -nr -k 3 | head -20

Answering your question finally this is what you would need to do get the memory utilzation for the processes run by a particular user. The below code will give top 20 memory consuming proceeses for that user
Code:
ps -U <user_name> -u <user_name>| awk '{print $1}' >pid.list
for i in `cat pid.list` ; do awk '/Rss/ {sum += $2}; END{if (sum>0) print FILENAME " Total: " sum/1024}' /proc/$i/smaps 2> /dev/null; done|sort -nr -k 3|head -20

And the below code will give you the total memory used by all the processes being run by that particular user
Code:
 for i in `cat pid.list` ; do awk '/Rss/ {sum += $2}; END{if (sum>0) print FILENAME " Total: " sum/1024}' /proc/$i/smaps 2> /dev/null; done| awk '{Avg += $3} END {print "Total memory: "Avg}'
Again this can be automated for any user using positional parameter in a shell script.

Last edited by Rohit_4739; 03-06-2013 at 05:23 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU utilisation - IS THIS EQUATION CORRECT chamila1986 Programming 3 03-10-2010 11:37 AM
RHEL 5.2 memory utilisation issue Aruna Ranathunga Linux - Newbie 1 12-29-2009 07:26 AM
inode utilisation is 99% nandu007 Linux - Server 1 06-04-2007 02:01 PM
cpu utilisation Moore Linux - General 2 06-25-2006 09:26 AM
effective utilisation of dual internet connections. exodist Linux - Networking 1 03-07-2006 10:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration