Script to identify high CPU usage processes


 
Thread Tools Search this Thread
Operating Systems AIX Script to identify high CPU usage processes
# 1  
Old 10-28-2010
Script to identify high CPU usage processes

Hi Guys,

I need to write a script capable of identifying when a high cpu utilitzation process. It sounds simple but we are on a AIX 5.3 environment with Virtual CPU's (VP's) and logical CPU's. Please any ideas or tips would be highly appreciated. Thanks.

Harby.
# 2  
Old 10-29-2010
check the C colmun of the ps output over several iterations and if the number is consitantly high(determined by what you think is high) then take action. you might also be able to run nmon in batch mode.
# 3  
Old 10-31-2010
but what really is confusing me that even I take the CPU% and then add them all together the number I get is not near close to what I can see in Topas or nmon.
# 4  
Old 11-01-2010
Quote:
Originally Posted by arizah
I need to write a script capable of identifying when a high cpu utilitzation process.
You could build something around the following command (read the man-page of "ps" for an explanation of the options used:

Code:
ps -Alo pcpu,vsz,pid,args | sort -rn

Basically this lists CPU consumption (pcpu) and virtual memory consumption (vsz) for each process and sorts for CPU consumption.

Quote:
Originally Posted by arizah
but what really is confusing me that even I take the CPU% and then add them all together the number I get is not near close to what I can see in Topas or nmon.
Again: read the man page of ps and that probably becomes clearer. You might also want to read Demystifying IOWAIT and AIX Process Priority and Control.

I hope this helps.

bakunin
# 5  
Old 11-03-2010
I use a command such as:

Code:
ps -eF "%C %u %n %p %a" | grep -vE "^ *0\.0|defunct|CPU|high_cpu|init"

If I remember right it won't match nmon because ps will list the CPU usage since the process started - not the instantaneous CPU usage.

Example output:

Code:
>high_cpu

=======================================================================================================================================
/home/unxsa/bin/high_cpu started at Wed Nov  3 07:24:34 CDT 2010 on ms.
=======================================================================================================================================
CPU    User       Nice   CPU  PID        Command
---------------------------------------------------------------------------------------------------------------------------------------
10.0   root       24     -    1147122    /usr/java5/jre/bin/java -Dhcdaemon -Dhmc -Djava.class.path=/opt/csm/codebase:/opt/freeware
0.2    root       20     -    307414     /usr/bin/dsmc sched
---------------------------------------------------------------------------------------------------------------------------------------

=======================================================================================================================================
/home/unxsa/bin/high_cpu ended at Wed Nov  3 07:24:34 CDT 2010 on ms.
=======================================================================================================================================

# 6  
Old 11-03-2010
ok ok I might be a bit stupid here but what would I possibly need such a script for. Nmon percentage shows cpu% of a cpu thread - not absolute cpu. And how big such a thread is depends highly on how you did setup your virtuals ... if you have 1 virtual = one physical cpu - and only one virtual cpu in your box - than 87% might be high ... if you have 30 virtuals together worth one physical cpu, than 87% is rather low. What I would look after is rather indeed what is consuming high amounts of cpu for longer periods of time (ps aux is helpful), and do I exhaust my box regarding cpus (i.e. going constantly over my entitlement / virtual limits). Again - when I have 1 virtual cpu and 1 cpu entitled than 100% cpu is the max I can go to - if you have 30 virtuals than 30 cpus (aka 3000% is the limit). When that happens once a day for 30 sec - not a reason for concern if I am the rest of the day below 100% (aka my entitlement) Smilie What I would probably frequently look after is rather how my cpu is used ... high usr cpu = good, high sys cpu = bad - there are applications like sybase which are spinning cpus so the system appears to be incredibly busy - but in fact it is very busy doing nothing - and root cause is underutilization ...
Other root causes for high cpu utilization might be a bottleneck in IO or memory ... not necessarily a particular process at all.
To say it with the words of IBM : in a virtualized environment on big frames cpu is these days not your problem ... There might be at times runaway processes hogging cpu - but you will more likely capture them running nmon a few times a day interactively and just look into what is under the top cpu consumers though not expected to be.

Kind regards
zxmaus
# 7  
Old 11-04-2010
Hi Everyone,

I really appreciate your valuable comments. The only reason I'm trying to come up with a script to monitor the CPU Utilization is because we are in the process of deploying a DB monitor and due some bugs sometimes once in while we get these CPU hogs processes spinning around chewing all the CPU. It has taken so long from the vendor to fix this software bugs and also I don't really want to take any chances so I would rather setup something to alert me or execute the workaround which is basically restarting the agent runing on the LPAR. Thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Identify cause of high resource usage

hello all, on linux servers sometimes any of these resources (cpu,memory,disk) get a spike when you are not in front of the server. the duration of these spikes might be 5 mins or even whole weekend. my question is there a good way of capturing the events that caused these issues ( cpu or... (5 Replies)
Discussion started by: coolatt
5 Replies

2. Solaris

How can i restrict user high cpu usage?

HI In my M5000 , one of domain is having SAp installed. from today onwards we are facing some stange issue. when we start SAP application, that particular user is taking 95 % of system CP and renaming 5 % is taken by system . because of this reason application is slow. i have 4 CPU(32... (4 Replies)
Discussion started by: bentech4u
4 Replies

3. Shell Programming and Scripting

High cpu usage

I have created one script and i have added it into cron to run after 10 mins. However I have noted that whenever that script runs, It causes CPU utilization of server to increase about 10-20 % I have rechecked script and there is no way i can make changes, Script contain only 2-3 commands. So... (4 Replies)
Discussion started by: Nakul_sh
4 Replies

4. AIX

High CPU Usage , users affected

Dear All, One production Server is affected by high usage. Application is slow now. Please guide me how to solve it? NMON Report shows full cpu usage. Here im posting some server details. bash-3.2# lparstat -i Node Name : ********* Partition Name ... (6 Replies)
Discussion started by: Thala
6 Replies

5. AIX

Identify All Processes memory and cpu usage.

Hi All, Anyone has script to monitor AIX total processes memory and cpu usage that contribute to the total memory and CPU utilize so far ? The purpose of this is to analyze process memory trend. Thanks. Best Regards, ckwan (2 Replies)
Discussion started by: ckwan
2 Replies

6. Linux

System Went panic after CPU usage high

Hi All, Yesterday my Linux server went panic and even a small command took a lot of time to run. When i monitored pl find the below output Cpu(s): 0.1%us, 98.4%sy, 0.0%ni, 1.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st the time spent on kernel mode is 98 % and also idle time is around 1.5 %...... (4 Replies)
Discussion started by: jegaraman
4 Replies

7. Shell Programming and Scripting

Identify CPU usage on the Linux server

We are using linux server. We have below script running on the crontab and it send the alert if the cpu usage is above 90%. My question is, the below script tells the CPU usage for one CPU or all CPU in the server? sar 1 1 | sed '$!d' | awk '{printf("%d", $8)}' > $SAR_LOG Please let me... (4 Replies)
Discussion started by: govindts
4 Replies

8. AIX

HELP!!! high CPU usage with ITM kuxagent

ibm tivoli monitor's kuxagent is taking up a lot of cpu usage. anybody has any idea? i attatched a screenshot. (3 Replies)
Discussion started by: curtis911
3 Replies

9. Ubuntu

High System CPU Usage

I am running a Dell PE R815 with 4 x AMD 12 core CPUs with 128GB of RAM and a RAID 5 array of 6 SAS disks. This is an HPC application and is definitely CPU bound, however once I run 16 of these processes (thus pinning 16 cores) the work performed slows down dramatically, to maybe 5 or 10% of what... (2 Replies)
Discussion started by: mowmentous
2 Replies

10. Shell Programming and Scripting

identify the unix processes performing high disk i/o reads and writes

I would like to write shell/perl script which identifies the top unix processes that are performing high disk I/O's or/and writes If any one knows the solution please help me? -Swamy (0 Replies)
Discussion started by: avsswamy
0 Replies
Login or Register to Ask a Question