Getting CPU% from a ps command (AIX 5.3)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting CPU% from a ps command (AIX 5.3)
# 1  
Old 09-28-2010
Getting CPU% from a ps command (AIX 5.3)

Hi,

I need write a script that check how much CPU% a particular process is using so I execute something like :
Code:
while :
do
      ps aux |  awk '{ if($3 < 10) {printf( "this process %s CPU: %f and process %d\n",$1,$3,$2)}}'
      sleep 300
done

but issue here is that I compare the number I get from the above command and the output I get from nmon is not even close :
Code:
Top-Processes-(253) ─────Mode=4  [1=Basic 2=CPU 3=Perf 4=Size 5=I/O 6=Cmds]
│  PID       %CPU     Size      Res     Res      Res     Char    RAM      Paging         Command                                                            
│            Used       KB      Set     Text     Data     I/O     Use   io   other repage                                                                   
│  426198    87.2   506400   339408       60   339348       31    1%      0     95      0 db2sysc                                                           
│ 2035930    40.1   282324   250896       60   250836     2328    1%      0     46      0 db2sysc

Does anyone know how from what other source I should get the CPU% so I get a number close like the one given by nmon. thanks.

Moderator's Comments:
Mod Comment Having so many posts already you should be familiar to code tags - so use them, thanks.

Last edited by zaxxon; 09-29-2010 at 05:23 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX CPU usage

hi, We have two LPARs, both have same capacity and believe same configuration. ulimit settings for oracle user is unlimited for both LPARs. Installed oracle databases with same configurations on both LPARs, both databases sync every second so volume is same. Both LPARs/databases have identical... (10 Replies)
Discussion started by: baladelaware73
10 Replies

2. Shell Programming and Scripting

CPU utilisation in AIX

Hi, I want to write one script that sent mail when CPU utilisation is more then 70%. i used topas but problem is it will show output only when we press ctrl +c. Please let me know if there is some other command that will give cpu utilisation which i can use in shell script. Thanks (3 Replies)
Discussion started by: ranvijaidba
3 Replies

3. Shell Programming and Scripting

AIX CPU performance script ?

I want to write a shell script which will print AIX CPU utilization memory utilization every 5 mins redirect to file. How do i do it? Please advise. Which commands I should use? (3 Replies)
Discussion started by: vegasluxor
3 Replies

4. AIX

How to calculate AIX CPU utilization using lparstat command

Could you please explain about calculate CPU utilization of aix server using lparstat command? Here below i have provided example output from aix test server. System configuration: type=Shared mode=Uncapped smt=On lcpu=4 mem=4096 psize=63 ent=0.50 %user %sys %wait %idle physc %entc ... (1 Reply)
Discussion started by: maruthu
1 Replies

5. AIX

AIX CPU waits

Guys, I have a question - when nmon reports a sizeable %CPU wait, does that mean - 1) IO operations are slowing CPU down, OR 2) paging slowing the CPU down, OR 3) one cant tell?? I thought the nmon documentation clearly suggested that CPU waits reported in nmon were from disk... (4 Replies)
Discussion started by: getback0
4 Replies

6. AIX

Aix process CPU differences.

Hi, I'm trying to create a script to catch a process which is consuming high CPU which I have pretty much done but it's just finding the correct place to pull the current CPU for that process. When viewed in Topas it's consuming 99.*% cpu But if I try using ps avg or ps -eo pcpu ... (5 Replies)
Discussion started by: elmesy
5 Replies

7. AIX

AIX CPU use

Hi Could somebody explain me how AIX is using CPU?? For example when we have 2 processors system is giving all task to one of them till 100% is used ?? Or it's depend on configuration or anything else ?? Best regards enda (3 Replies)
Discussion started by: enda
3 Replies

8. AIX

Find CPU per process in AIX

Hi. I am looking for a command that will return me the amount of CPU used by a specific process in AIX environment. I know there is TOPAS - but it is interactive and I need to get this information from system that connects remotely via SSH. Using writing to files and than reading them is also... (1 Reply)
Discussion started by: yamsin789
1 Replies

9. AIX

no of core in cpu for aix

is there command which will display no of core per cpu in aix? Regads, Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies

10. AIX

Aix high cpu activity

Hello everyone I have this process running on my server. topas command User 98.6 |############################ I have this process Name PID CPU% PgSp Owner db2fm 565264 25.6 1.5 ldapdb2 db2fm 348328 23.6 ... (4 Replies)
Discussion started by: lo-lp-kl
4 Replies
Login or Register to Ask a Question