determine total memory used by some user/process


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers determine total memory used by some user/process
# 1  
Old 08-12-2009
determine total memory used by some user/process

HI guys,

Smiliei would like to know how can i determine
the total/approx memory used by a single user. Example Top output is below

===========================================================================
Code:
top - 20:00:50 up 24 days,  2:48,  2 users,  load average: 0.43, 0.40, 0.37
Tasks: 172 total,   2 running, 170 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.3% us,  0.7% sy,  0.0% ni, 95.0% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:  24954784k total, 23561312k used,  1393472k free,   318788k buffers
Swap:  2031608k total,        4k used,  2031604k free, 21011868k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 7172 rtx       16   0 73696  34m 3352 R   10  0.1 247:50.05 mysqld
 5189 rtx       16   0  322m 316m 4268 S    3  1.3  60:50.34 some.f
 5193 rtx       16   0  327m 321m 4264 S    2  1.3  60:14.19 some.f
16015 rtx       15   0 73696  34m 3352 S    1  0.1 139:45.09 mysqld

===========================================================================

From the Top output above i found that the memory usage is about 94%. There are about 45 processes owned by "rtx" user.Am wondering if there is any method i

Last edited by vgersh99; 08-12-2009 at 03:43 PM.. Reason: code tags, PLEASE!
# 2  
Old 08-12-2009
Your server looks pretty healthy. Don't be fooled by the 94% you're seeing there. The way that that is reported isn't truly accurate. Buffers and cache are shown as "used memory" but in fact they are available to the system if needed.

For example, if I look at the server I'm working on right now, using top, I see:
Code:
top - 11:23:56 up 32 days, 11:11, 37 users,  load average: 2.79, 4.63, 4.55
Tasks: 365 total,   3 running, 362 sleeping,   0 stopped,   0 zombie
Cpu(s): 28.1% us, 11.4% sy,  0.5% ni, 46.2% id, 13.8% wa,  0.0% hi,  0.0% si
Mem:   3984940k total,  3666912k used,   318028k free,     2156k buffers
Swap:  2096472k total,     2136k used,  2094336k free,  2533372k cached

This makes it look like my memory is all used up. (in fact, I'm 2 meg into swap which I don't like. I'll have to look at that.)

But if I look at it using "free":
Code:
             total       used       free     shared    buffers     cached
Mem:       3984940    3934792      50148          0       3348    2628640
-/+ buffers/cache:    1302804    2682136
Swap:      2096472       2136    2094336

You can see, from the bolded line, that if you factor out buffers/cache (which you should) I have about 2.5GB of "free" memory. What's most important when looking at top for memory usage (at least in my opinion) is to look at the amount of swap used. Swap should never be used. If it is it's indicative of a problem. Memory leak, underpowered server, etc.

That being said, if you want to know usage for a user you should use 'ps' and then extract the data from there. You can grep by the user name and then use awk to extract the field you want and perform calculations on it.
# 3  
Old 08-12-2009
Code:
ps -u <user> -lf -o user,comm,vsz

This will provide virtual memory used per process owned by a user.

Last edited by Padow; 08-12-2009 at 04:11 PM.. Reason: Added code brackets
Padow
# 4  
Old 08-12-2009
Hi mglenney & Padow ,

Thanks alot for your replies, i have finally found out that with awk i can find out what i need.Thanks again for your support and have a great day Smilie

#ps aux | grep --exclude=grep rtx | grep -v grep | awk 'BEGIN{s=0;} {s=s+$6;}END{print s;}' // for total memory

#ps aux | grep –exclude=grep rtx |grep –v grep | awk ‘BEGIN{s=0;} {s=s+$6;} END {print s/45;}’ // for average memory
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Process, PID and total memory consumed on AIX.

Hi, Below is the code snippet I use on Linux (Centos) to retrieve the Process Name, PID and memory consumed on Linux (Centos) host:- top -b -n 1 | awk -v date="$tdydate" -v ip="$ip" 'NR>7 {print date","ip","$12,","$1,","$10}' Any idea how the same can be retrieved on an AIX host? This... (1 Reply)
Discussion started by: Vipin Batra
1 Replies

2. Solaris

T5220 How to determine physical memory installed?

Hi, looking to upgrade memory on a pair of T5220's from 32GB to 64GB. Cannot determine current DIMM size and slots used. i.e. not sure if Qty 16 x 2GB or Qty 8 x 4GB. If there are no empty slots, i need to go with higher density DIMMs and retire exsisting the 2GB prtdiag follows. #... (3 Replies)
Discussion started by: edrew
3 Replies

3. Red Hat

Total Memory

Hi, I have a strange issue where the total memory on the server is showing low. At the moment 8 GB of memory is installed and only 3 GB is showing on the shell prompt. I am using the commands free -m and vmstat to check the memory. Please help me out in identifying the issue. With regards... (3 Replies)
Discussion started by: shabu
3 Replies

4. Shell Programming and Scripting

Total usage memory by user

Hi, When running top on linux redhat machine , i see that i have 16gb of memory in my machine and about 14.5gb of memory are in use: Mem: 16395780k total, 14970960k used, 1424820k free, 370264k buffers Swap: 4192956k total, 25824k used, 4167132k free, 12029400k cached How can i... (3 Replies)
Discussion started by: yoavbe
3 Replies

5. Solaris

How to find Total and Free Physical Memory and Logical Memory in SOLARIS 9

Hi, Im working on Solaris 9 on SPARC-32 bit running on an Ultra-80, and I have to find out the following:- 1. Total Physical Memory in the system(total RAM). 2. Available Physical Memory(i.e. RAM Usage) 3. Total (Logical) Memory in the system 4. Available (Logical) Memory. I know... (4 Replies)
Discussion started by: 0ktalmagik
4 Replies

6. UNIX for Dummies Questions & Answers

How to accurately determine memory (RAM) information

I'm writing a shell script to display as much useful information on physical and virtual memory availability and usage as possible. I need a CLI tool to print these numbers for me. The utilities that I know to give out some statistics are the following: free top vmstat sysctl In Linux... (1 Reply)
Discussion started by: fiori_musicali
1 Replies

7. UNIX for Dummies Questions & Answers

how can i get The total size of the process in virtual memory om GB or MB

Hello all im using the ps -ef "args vsz" | some.exe but the result is in kb , is there some kind of way or flag ( didnt found in the ps man ) to convert me this data to GB or MG in human readable format ? Thanks (1 Reply)
Discussion started by: umen
1 Replies

8. HP-UX

How to determine cpu&memory percentage usage per user

Using HP-UX v11 Need to monitor cpu and memory usage, total for system and separately for each user in command-line mode. Found out next ways to monitor total cpu usage under hp-ux: 1) vmstat, also shows free memory 2) sar -M ps -eo user,pcpu - does not work, means 'user-defined format'... (4 Replies)
Discussion started by: hp-ux-user
4 Replies

9. Filesystems, Disks and Memory

Total Memory/Swap Memory

I need to put a program together to determine the total, available memory and total and available swap on unix machines. I have been searching for weeks and I seem to run into dead ends. Every unix platform I look at has a different way to determine memory info. Any sugggestions or new... (4 Replies)
Discussion started by: ghe1
4 Replies
Login or Register to Ask a Question