1834486 Members
3335 Online
110067 Solutions
New Discussion

Re: Memory

 
Nitsulenko Sergey
Frequent Advisor

Memory

Hi,
Is it possible to get the list of processes the heaviest from the point of view of loading memory?
sin
5 REPLIES 5
Steve Steel
Honored Contributor

Re: Memory

hi

#!/usr/bin/ksh
#
# Show processes sorted by size of core image
#
# Usage:
# psram [ quantity ]
#
# 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,pid,args > $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 -k2 | head -${TOPPROCS}
rm $TEMPFILE > /dev/null 2>&1
#### END OF SCRIPT

will do it

And for cpu 2 lines

echo " $(UNIX95= ps -e -o pcpu -o ruser -o sz -o vsz -opid -o args|head -n1)"
UNIX95= ps -e -o pcpu -o ruser -o sz -o vsz -opid -o args|grep -v %CPU| sort -nr|tail -n +2|head -n 20

Regards


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Bill McNAMARA_1
Honored Contributor

Re: Memory

Check Yogeeraj response in the thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html

Later,
Bill
It works for me (tm)
Bill McNAMARA_1
Honored Contributor

Re: Memory

well, he posted a few times: here's the direct link:
http://forums.itrc.hp.com/cm/components/FileAttachment/0,,0xbe83107d277ad611abdb0090277a778c,00.txt
It works for me (tm)
Nitsulenko Sergey
Frequent Advisor

Re: Memory

It's OK! Thanks!
sin
Stanimir
Trusted Contributor

Re: Memory

Hi!
I've sent script, that has
very useful functions. It could be part of /etc/profile
Regards.