Re: CPU Utilized (279 Views)
Reply
Advisor
unix55
Posts: 29
Registered: ‎07-17-2011
Message 1 of 10 (330 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,700
Registered: ‎03-06-2006
Message 2 of 10 (321 Views)

Re: CPU Utilization

[ Edited ]

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

Please use plain text.
Super Advisor
Mousa55
Posts: 663
Registered: ‎05-20-2007
Message 3 of 10 (319 Views)

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

 

 

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,700
Registered: ‎03-06-2006
Message 4 of 10 (317 Views)

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=

 

Please use plain text.
Super Advisor
Mousa55
Posts: 663
Registered: ‎05-20-2007
Message 5 of 10 (315 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,700
Registered: ‎03-06-2006
Message 6 of 10 (312 Views)

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.

Please use plain text.
Super Advisor
Mousa55
Posts: 663
Registered: ‎05-20-2007
Message 7 of 10 (296 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,700
Registered: ‎03-06-2006
Message 8 of 10 (293 Views)

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

Please use plain text.
Frequent Advisor
basant
Posts: 52
Registered: ‎08-04-2011
Message 9 of 10 (292 Views)

Re: CPU Utilized

you can use following hpux utilities to get CPU Utilized.

1. top

2. sar

3. glance

 

Basant Sharma
Please use plain text.
Valued Contributor
Naj
Posts: 169
Registered: ‎06-16-2011
Message 10 of 10 (279 Views)

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!
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation