Operating System - HP-UX
1753734 Members
4499 Online
108799 Solutions
New Discussion юеВ

Re: top 10 process with ps on hpux 11.11

 
SOLVED
Go to solution
Simon Jespersen
Frequent Advisor

top 10 process with ps on hpux 11.11

Hi could someone please help me out, i would like to do 3 ps cmds in a script
1. showing top 10 cpu consumers
2. top 10 memory consumers.
3. top 5 iowait (processes or diskusers)


7 REPLIES 7
Arunvijai_4
Honored Contributor
Solution

Re: top 10 process with ps on hpux 11.11

Hi,

# UNIX95= ps -ef -o pid,ruser,vsz,args|sort -nrk3


# UNIX95= ps -ef -o pid,ruser,pcpu,args|tr -d "%" |awk '{if($4>=90) print $0}'

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Simon Jespersen
Frequent Advisor

Re: top 10 process with ps on hpux 11.11

Thank you very much.
does UNIX95= ps -ef -o pid,ruser,vsz,args|sort -nrk3 show the meory in blocks or kb ? i would like to calculate it to mb.

What does the UNIX95 mean... is it an older shell interpreter
Arunvijai_4
Honored Contributor

Re: top 10 process with ps on hpux 11.11

Hi,

Regarding UNIX95, this has been discussed already in the forums many times, you can see these threads for more information,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=4177
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=943707

-Arun

P.S Dont forget to assign points.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Simon Jespersen
Frequent Advisor

Re: top 10 process with ps on hpux 11.11

Thank you very much. It is my first time in this forum.
Arunvijai_4
Honored Contributor

Re: top 10 process with ps on hpux 11.11

Forgot to mention, vsz is in KB and its only an approximation.

-Arun

"A ship in the harbor is safe, but that is not what ships are built for"
Geoff Wild
Honored Contributor

Re: top 10 process with ps on hpux 11.11

Here's a little script for you

#!/bin/sh
# memtop - show top memory users and pid
# VSZ is in KB
echo "VSZ(KB) PID RUSER COMMAND"
UNIX95= ps -e -o 'vsz pid ruser args' |sort -nr|head -30

Next one tells you memory claimed by an ndividual process:

# cat processmem
#!/bin/sh
# processmem - display memory claimed by a process
# gwild 03192004
#
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "processmem \"process\""
echo "Example:"
echo "processmem rpc"
exit 1
fi
echo " "

PROCESS=$1

mps=0
#for sz in `ps -elf | grep $PROCESS | grep -v grep | awk '{print $10}'`
for sz in `UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes | grep $PROCESS | awk '{print $1}'`
do
mps=`expr $mps + $sz`
done
#echo `expr $mps \* 4096`
echo "\nMemory claimed by $PROCESS: $mps Kbytes.\n"


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Arturo Galbiati
Esteemed Contributor

Re: top 10 process with ps on hpux 11.11

Hi Simon,
1. echo " %CPU PID RUSER COMMAND" ;UNIX95= ps -ef -o 'pcpu pid ruser args'|sort -nr|head -10
2. echo " VSZ PID RUSER COMMAND";UNIX95= ps -ef -o 'vsz pid ruser args' |sort -nr|head -10
3. This gives you the lists of the process in wait state
UNIX95= ps -ef -o 'wchan state pid ruser args'|awk '$2=="W"||$1=="WCHAN"'

HTH,
Art