Need a list of top 10 CPU using processes (also top 10 memory hogs, separately)

Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold

I use top on other platforms but on AIX, I was not able to find top, but only topas. Unfortunately topas do not have an option of running in batch mode. For instance, I can tell top to run for one count/iteration and wite the output to a file, which in turn can be beaten up using any text processors to display the output I desire. topas can't

I tried using the output of ps -ef |sort -n -k 7 but 7th field is returning wonky results on the output of ps -ef. SO this stopped being an option.

Is there any way to get an output from topas as one can get from top ? If yes, how ? I am also open to other suggestions than topas as the monitor. I also have nmon on these aix boxes if it can be used for this purpose.

Thanks for all suggestions in advance.

on4:/home/vbe $ oslevel;UNIX95=1 /usr/bin/ps -e -o pcpu,args | /bin/sort -u -r | sed -e 's/\.[0-9][0-9]/&\%/g>
5.3.0.0
  2.3 expres63 /tmp/xsauthn /tmp/xsauthz POFA1 25 28 29 32 648019971 148897804 
  0.1 PatrolAgent 
  0.0 xsauthz -s /tmp/xsauthz 
  0.0 xsauthn -s /tmp/xsauthn 
  0.0 xsagent 9457 /opt/ofa/oes634/olap/log/xsagent.log 
  0.0 sendmail: accepting connections 
  0.0 rlogind 
  0.0 p_ctmat 
  0.0 p_ctmag 
  0.0 ds_listener -port=50005 -hosts= -period=3 -interval=1440 -log=/opt/patrol/dsclient/log/dslistener.log -start 

---------- Post updated at 18:26 ---------- Previous update was at 18:25 ----------

works also for HPUX...

---------- Post updated at 18:32 ---------- Previous update was at 18:26 ----------

on4:/home/vbe $ UNIX95=1 /usr/bin/ps -e -o vsz,args | /bin/sort -u -r | sed -n 2,11p
844780 expres63 /tmp/xsauthn /tmp/xsauthz POFA1 25 28 29 32 648019971 148897804 
16080 /usr/tivoli/tsm/client/ba/bin/dsmc sched 
15164 /usr/sbin/rsct/bin/IBM.CSMAgentRMd 
110156 /usr/bin/xmwlm -L 
 7176 bgscollect -I noInstance -B /opt/patrol/Patrol3.5/AIX5.3.0.0-64/best1/7.3.00 
 2964 /opt/patrol/Patrol3.5/AIX5.3.0.0-64/best1/7.3.00/bgs/bin/dcm -f /opt/patrol/Patrol3.5/AIX5.3-64/log/patrol.FIFO-morgon04-3181
 2948 /opt/OmniVision/bin/omv_bdc -OW -D /opt/OmniVision/data 
 2636 /usr/sbin/rsct/bin/rmcd -a IBM.LPCommands -r 
 2552 /usr/sbin/nmon_aix53 -A -R -F /tmp/nmon_grapher.data.1004034 -c 49 -s 300 
 2340 /opt/ofa/oes634/olap/bin/xsdaemon 

---------- Post updated at 18:35 ---------- Previous update was at 18:32 ----------

but Im no AIX specialist and waiting for my boss to send me follow some courses such as AW18FR...(and after AU73FR... I can always dream...)

Thank you.. The output will be sufficient for a quick and dirty peek at the CPU hogs.

---------- Post updated at 10:20 AM ---------- Previous update was at 09:51 AM ----------

my hpux solution:
top -d 1 -n 10 -f /tmp/file; tail -11 /tmp/file

my Linux (RHEL) solution:
top -b -n 1 | sed -e "1,6d" | head -11

fyi...

Forgot... the second code was for memory...

Hi,

for AIX I am using:

Displaying top CPU_consuming processes

ps aux | head -1; ps aux | sort -rn +2 | head -10 

Displaying top 10 memory-consuming processes

ps aux | head -1; ps aux | sort -rn +3 | head

Displaying the process in order of real memory use

ps vx | head -1; ps vx | grep -v PID | sort -rn +6 | head -10

Displaying process in order of nice value

ps -eakl | sort -n +7 

Displaying the process in order of I/O

ps vx | head -1; ps vx | grep -v PID | sort -rn +4 | head -10 

Kind regards
zxmaus

1 Like

This is cool stuff.. Thanks zxmaus