Showing results for 
Search instead for 
Do you mean 

CPU Utilized

Advisor

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
Acclaimed Contributor Acclaimed Contributor

Re: CPU Utilization

[ Edited ]

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

Super Advisor

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 Acclaimed Contributor

Re: CPU Utilization

[ Edited ]

>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=

 

Super Advisor

Re: CPU Utilized

Hi,

 

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

 

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


12616 elink     0.34 perl_node
25954 elink     0.14 c_node
13969 elink     0.16 perl_node
 9544 elink     0.77 perl_node
22468 elink     0.14 perl_node
 8677 elink     0.19 c_node
16422 elink     0.38 perl_node
16835 elink     0.75 c_node
16046 elink     0.19 perl_node
22348 elink     0.25 perl_node
 8389 elink     0.24 perl_node
22446 elink     0.21 perl_node
12928 elink     0.50 perl_node
 7742 elink     0.33 perl_node
16539 elink     0.19 perl_node
11091 elink     0.42 perl_node
12487 elink     0.51 c_node
10736 elink     0.78 perl_node
24487 elink     0.37 perl_node
  441 elink     1.96 perl_node
25203 elink     0.21 perl_node

 

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

 

Thanks

Acclaimed Contributor Acclaimed Contributor

Re: CPU Utilization

[ Edited ]

>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.

Super Advisor

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 Acclaimed Contributor

Re: CPU Utilization

[ Edited ]

>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).

Frequent Advisor

Re: CPU Utilized

you can use following hpux utilities to get CPU Utilized.

1. top

2. sar

3. glance

 

Basant Sharma
Highlighted
Valued Contributor

Re: CPU Utilized

Hi

 

How about this?

 

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!