1834934 Members
2722 Online
110071 Solutions
New Discussion

Re: CPU UTILIZATION

 
SOLVED
Go to solution
Rana_2
Frequent Advisor

CPU UTILIZATION

hi,

I need same help on extracting process that consuming higher percentage of cpu using top command

plz,I NEED THIS IN SHELL SCRIPTING (hp-ux 11)
4 REPLIES 4
James Murtagh
Honored Contributor
Solution

Re: CPU UTILIZATION

Hi Rana,

If you really need to use top you could write the script like :

#!/usr/bin/ksh

TEMPFILE=/var/tmp/top.$$

top -n1 -f $TEMPFILE

cat $TEMPFILE | tail -2 | awk '{print $12,$13}'

rm $TEMPFILE

However, this will be a lot slower than something like :

#!/usr/bin/ksh

export UNIX95=XPG4

ps -efo pcpu,comm | sort -r | head -2

Simply because of the amount of data top has to collect and the IO taking place.

Regards,

James.
Rana_2
Frequent Advisor

Re: CPU UTILIZATION

thanx James,

The top commad work perfect,
but the ps -ef giving wrong process.
James Murtagh
Honored Contributor

Re: CPU UTILIZATION

Hi Rana,

The output may be different every time you run this as it only reports the process using the highest percentage of the CPU in that interval. There was an issue with the ps command on 11.00, fixed with the following patch:

PHCO_18446 s700_800 11.00 ps(1) cumulative patch

This patch has no dependencies and does not require a reboot. However, the latest and recommended ps patch is PHCO_26274 and has a couple of dependencies, which will require a reboot if the kernel dependencies are not already installed.

Regards,

James.
Steven E. Protter
Exalted Contributor

Re: CPU UTILIZATION

Here is a handy shell script to collect performance data on your system. It can be adapted to whatever time period you wish and runs background. ATTACHED

I've had the same issue as the patches noted above me in the thread, getting those patches in and the March 2003 Quality Pack are a good idea.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com