1834318 Members
2276 Online
110066 Solutions
New Discussion

System performance

 
Prashant Zanwar_4
Respected Contributor

System performance

Does anyone have a way to sort Memory usage per process? Please provide if anyone uses script to do this!
Thanks and regards
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
9 REPLIES 9
twang
Honored Contributor

Re: System performance

#!/bin/sh
echo "VSZ(KB) PID RUSER COMMAND"
UNIX95= ps -e -o 'vsz pid ruser args' |sort -nr |more
Kent Ostby
Honored Contributor

Re: System performance

When I am having memory problems, I sometimes go looking for the cpu usage off of ps since heavy CPU usage correlates at times to the memory usage:

ps -ef | sort -nr -k42,80 | head

Then repeat it a few seconds later to see where the CPU time is being burned up.

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Nobody's Hero
Valued Contributor

Re: System performance

sort -rn -k 2
UNIX IS GOOD
Nobody's Hero
Valued Contributor

Re: System performance

Sorry, here is the script I use.

where quantity is the top RAM processes to show (default is 20)
#
set -u
if [ $# -gt 0 ]
then
TOPPROCS=$1
else
TOPPROCS=20
fi

MYNAME=$(basename $0)
TEMPFILE=/var/tmp/$MYNAME.$$
trap `rm -f $TEMPFILE > /dev/null 2>&1` 0 1 2 3 15

UNIX95= ps -e -o ruser,vsz=Kbytes -o pid,args=Command-Line > $TEMPFILE
head -1 $TEMPFILE
DASH5="-----"
DASH25="$DASH5$DASH5$DASH5$DASH5$DASH5"
echo "$DASH5---- $DASH5- $DASH5 $DASH25$DASH25"
grep -v "VSZ COMMAND" $TEMPFILE \
| cut -c -78 \
| sort -rn -k 2 \
| head -${TOPPROCS}

rm $TEMPFILE > /dev/null 2>&1

UNIX IS GOOD
Prashant Zanwar_4
Respected Contributor

Re: System performance

Thanks both..For some reason I am not able to work with 1st option UNIX95...
Is there any way to know IO per process..
Will be very gr8 help..
Thanks and regards
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Patrick Wallek
Honored Contributor

Re: System performance

Note that there MUST be a space between UNIX95= and the ps command.

Like:

# UNIX95=ps...........
Prashant Zanwar_4
Respected Contributor

Re: System performance

thats all gr8...
I wanted something to sort processes per IO usage...It's quite complicated and not straight always to look at IO hits and then drill thru processes..does anyone uses any script for this..One of my server is trashing..heavy IO also..Please help..
Thx
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Chris Vail
Honored Contributor

Re: System performance

You've mentioned one of the main reasons that HP sells glance. I recommend it. Like someone else posted, whenever I see heavy memory usage I use:
ps -ef|sort -k 4nr,4|pg
to see which processes are hitting the system the hardest. But Glance has all this good stuff for you already sliced, diced and graphical.


Chris
TwoProc
Honored Contributor

Re: System performance

Prashant - Chris is right - Glance is the tool for this job. You can load it right off the install CD's for a free 30 day trial. HP is hoping you get hooked on it and therefore buy it - and you probably should, it really makes life simpler for these sorts of issues.
We are the people our parents warned us about --Jimmy Buffett