# Re: CPU Utilized

## CPU Utilized

Hi,

How can i know the percentage of CPU utilized by such process or by user, for example the percentage for all the root user process.

Thanks

9 REPLIES 9
Acclaimed Contributor

## Re: CPU Utilization

top will give the percentage for each process.  For a user, you would have to add them up.

## Re: CPU Utilized

Hi,

ok, but I want to know the percentage of specific process on total CPU number, not on one CPU.

"For a user, you would have to add them up."  do you mean

# top root     =========> but i don't see any output related to root user

Thanks

Acclaimed Contributor

## Re: CPU Utilization

>I want to know the percentage of specific process on total CPU number, not on one CPU.

Then you just divide by the total number of CPUs.

>top root  => but I don't see any output related to root user

You would need to add up all of the processes owned by root.  Using ps(1) may be easier:

UNIX95=EXTENDED_PS ps -u root -opid= -ouser= -opcpu= -ocomm=

## Re: CPU Utilized

Hi,

thanks for your suppor, but What is the third line ?

# UNIX95=EXTENDED_PS ps -u elink -opid= -ouser= -opcpu= -ocomm=

< Then you just divide by the total number of CPUs > can you give me example

Thanks

Acclaimed Contributor

## Re: CPU Utilization

>What is the third line?
> UNIX95=EXTENDED_PS ps -u elink -opid= -ouser= -opcpu= -ocomm=

The third column is the percentage CPU time.

>Then you just divide by the total number of CPUs. Can you give me example:

UNIX95=EXTENDED_PS ps -u elink -opid= -ouser= -opcpu= -ocomm= |

awk -v cpus=\$NUM -v user=elink '

{

cpu_percentage += \$3

}

END { print "Total machine usage for", user ":", cpu_percentage / cpus; }'

Where \$NUM is the number of CPUs on your machine.

## Re: CPU Utilized

Hi,

thanks for your support, but i have the last quetions

how to get sar output of CPU utlization for 1 day and save it to file.

Thanks

Acclaimed Contributor

## Re: CPU Utilization

>how to get sar output of CPU utilization for 1 day and save it to file.

Take a look at sar(1m), sadc(1m), sa1(1m) and sa2(1m).

## Re: CPU Utilized

you can use following hpux utilities to get CPU Utilized.

1. top

2. sar

3. glance

Basant Sharma
Valued Contributor

## Re: CPU Utilized

Hi

UNIX95= ps -e -o "pcpu args" |sort -r | head -20

sample output

# UNIX95= ps -e -o "pcpu args" |sort -r | head -20
1.27 vxfsd
0.37 /opt/OV/bin/ovcd
0.32 /opt/wbem/lbin/cimprovagt 17 15 HPUXIOTreeIndicationProviderModule
0.23 /opt/hpservices/jre/opt/java1.4/jre/bin/IA64N/java -Xmx512m -DRunnerValuePairFile=/var/opt/runner/data/valuePairs -cp /opt/runn
0.20 vxsvc -r /opt/VRTSob/config/Registry -e
0.20 /opt/wbem/lbin/cimprovagt 13 11 SFMProviderModule
0.20 /opt/OV/lbin/eaagt/opcmsga
0.18 /opt/OV/lbin/conf/ovconfd
.

.

Thanks

____________________________________________
:: Really appreciate if you could assign some points.
:: Don't know how to assign point? Click the KUDOS! star!