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

Likee this guy: [Solved] AIX UNIX CPU Utilization Scripts

You could try running something like this every 5 mins with cron:

#!/bin/ksh
#
# Run via cron every 5 minutes
# send email if IDLE below LIMIT for more than CMAX times
#
INTERESTED=AIXsupport@your.company.com
HOST=$(hostname -s | tr '[a-z]' '[A-Z]')
IDLE=$(sar 5 6 | awk '$1~"Average"{printf "%.0d", $8}')
LIMIT=30
CMAX=4

CHKFILE=/tmp/cpu_check.txt

CPUCNT=0
[ -f $CHKFILE ] && read CPUCNT < $CHKFILE 

if [ $IDLE -lt $LIMIT ]
then
  let CPUCNT+=1
  [ $CPUCNT -eq $CMAX ] && echo "CPU usage has been above $((100 - LIMIT))% for longer than $((5*CMAX))mins" | mail -s "$HOST, Sustained high CPU usage: $((100 - IDLE))%" $INTERESTED
else
  [ $CPUCNT -ge $CMAX ] && echo "CPU usage has now returned to less than  $((100 - LIMIT))%" | mail -s "$HOST, CPU usage normalised: $((100 - IDLE))%" $INTERESTED
  CPUCNT=0
fi

echo "$CPUCNT" > $CHKFILE

You many have to tweak the below line to get correct idle CPU on AIX:

sar 5 6 | awk '$1~"Average"{printf "%.0d", $8}'

You can let sar give you a new line every 5 minutes, in an oigoing process, and decide if you want to alert or log or whatever for each line.