Microsoft
Software
Hardware
Network
Question : Script for AIX processes working set size
I am trying to write a korn shell script for AIX to determine the working set size of all running processes on a system.
IBM provided a bit of perl code to minimize the output of svmon to just the summary line. From that, I can read
inuse memory, pinned memory, paging space and virtual memory values.
Here is what I have so far:
--------------------------
----------
--
#!/bin/ksh
# Working set size
# svmon -P
let cnt=0
svmon -P | perl -e 'while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^-+$/)}' | \
while read -r pid cmd inuse pin pgsp virt flags ; do
# Note, the above two lines are actually one script line
# It is broken out for readability
let cnt=cnt+1
if [ cnt -lt 3 ] # read only from 3rd line forward (ignore heading lines)
then
continue
else
let wspg=$inuse+$pgsp+$virt
let ws=$wspg*4
# Convert from 4K pages to KBytes
echo "PID $pid Working Set Size $ws KB"
fi
done
--------------------------
----------
--
Am I on the right track here? Are the values obtained this way (in use memory + paging space + virtual memory) going to give me a close approximation to the point-in-time working set size of a process?
Thank you.
Answer : Script for AIX processes working set size
Yes. I've extracted the explanation of SIZE and RSS from "AIX 5L Performance and System Tuning"
Use of the ps command in a memory usage study
The ps command can also provide useful information on memory usage.
The SIZE column
The v flag generates the SIZE column. This is the virtual size (in the paging
space), in kilobytes, of the data section of the process (displayed as SZ by other
flags). This value is equal to the number of working segment pages of the
process that have been touched times four. If several working segment pages
are currently paged out, this number is larger than the amount of real memory
being used. SIZE includes pages in the private segment and the shared-library
data segment of the process, as in the following example:
# ps av |sort +5 -r |head -n 5
PID TTY STAT TIME PGIN SIZE RSS LIM TSIZ TRS %CPU %MEM COMMAND
25298 pts/10 A 0:00 0 2924 12 32768 159 0 0.0 0.0 smitty
13160 lft0 A 0:00 17 368 72 32768 40 60 0.0 0.0/usr/sbin
27028 pts/11 A 0:00 90 292 416 32768 198 232 0.0 1.0 ksh
24618 pts/17 A 0:04 318 292 408 32768 198 232 0.0 1.0 ksh
The RSS column
The v flag also produces the RSS column, as shown in the previous example.
This is the real-memory (resident set) size in kilobytes of the process. This
number is equal to the sum of the number of working segment and code segment
pages in memory times four. Remember that code segment pages are shared
among all of the currently running instances of the program. If 26 ksh processes
are running, only one copy of any given page of the ksh executable program
would be in memory, but the ps command would report that code segment size
as part of the RSS of each instance of the ksh program
Random Solutions
html select storing more than one value against an option
How can I kill process in SQL.
Disk Full Error on Win2k Server Mapped Drive from Office Apps.
conditions (if,then,else) in SQL
Active Directory Design with Child domain authenticating to Parent Domain
bash shell-- passing var back to shell, to pass to another script
Subform: me.dirty not working
How to simulate a keypress in Flash actionscript 2.
WSS 3.0 -> setting up calendar to invite people on event
MS DOS and SATA