Operating System - HP-UX
1833588 Members
3947 Online
110061 Solutions
New Discussion

What process is using what cpu?

 
ROSS HANSON
Regular Advisor

What process is using what cpu?

Is there a script to find which process is "hammering" cpu0. We have 4 cpus in a N4000 box
with hpux 11i
Ross Hanson
11 REPLIES 11
Uday_S_Ankolekar
Honored Contributor

Re: What process is using what cpu?

Easy way is top command
It will show you which process is running on what cpu

-USA..
Good Luck..
Caesar_3
Esteemed Contributor

Re: What process is using what cpu?

Hello!

In top you can see it.

Caesar
John Dvorchak
Honored Contributor

Re: What process is using what cpu?

If you want to do this as a script, so you can run it from cron etc, then use this little snippet:

top -s 10 -d 5 -f /tmp/top.out

That will run top refreshed every 10 seconds for 5 iterations and put the output in the file /tmp/top.out.

man top
If it has wheels or a skirt, you can't afford it.
twang
Honored Contributor

Re: What process is using what cpu?

use "top" to display top processes on system:
# top
eg.
TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
? 6339 oradb 240 20 369M 12856K run 860:46 99.51 99.34 oracleprod
? 29 root 152 20 1856K 0K run 0:58 1.13 1.13 vxfsd
pts/0 7284 root 178 20 2864K 424K run 0:00 0.23 0.10 top

The CPU column shows the CPU# the process is executing.
The TIME column shows the time the process consumed.
The %CPU column shows the raw CPU percentage.
Sridhar Bhaskarla
Honored Contributor

Re: What process is using what cpu?

Hi Ross,

Along with top, you can use 'ps' also to get the information.

export UNIX95=1
ps -ef -o "pcpu args" |sort -n

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Bill Hassell
Honored Contributor

Re: What process is using what cpu?

Note that CPU 0 will always be the first one to be hammered if there aren't any other processes using a lot of CPU. There's nothing wrong with that, if more processing power is needed for other programs then the other CPUs will become active. To see this in action (use top to monitor), use this very simple script:

while :
do :
done

This will do nothing but burn CPU cycles. Start multiple copies and you'll see top display the distribution of CPU cycles. Note also that HP-UX will change CPUs for the same process quite often. There's nothing to move in doing this--all the CPUs see all of memory.


Bill Hassell, sysadmin
twang
Honored Contributor

Re: What process is using what cpu?

Agree with Sridhar, you may issue this:

UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | more

Tim D Fulford
Honored Contributor

Re: What process is using what cpu?

Some more options

o Glance, then select process
o ps -elp
o MeasureWare

Regards

Tim
-
Tim D Fulford
Honored Contributor

Re: What process is using what cpu?

oops

my ps command should read
o ps -flp

Or if you want it for all processes
o ps -fel

The 6th column labled C is the CPU#
-
Paula J Frazer-Campbell
Honored Contributor

Re: What process is using what cpu?

Ross

Some catching up to do:-

This member has assigned points to 10 of 129 responses to his/her questions.


Please assign points to those who have used their own time to assist you.

Paula
If you can spell SysAdmin then you is one - anon
Paula J Frazer-Campbell
Honored Contributor

Re: What process is using what cpu?

Ross

Some catching up to do:-

This member has assigned points to 10 of 129 responses to his/her questions.


Please assign points to those who have used their own time to assist you.

Paula
If you can spell SysAdmin then you is one - anon