User Tools

Site Tools


aix:collect_perf

Scripts to collect perf

NMON example

NMON is natively integrated to AIX OS, so you can also use it to collect perf evey 30 seconds and count of 2880, so for 24 hours. When finish, you can use the .nmon file and analyse it with NMON analyser (excel)

root@prod /var/nmon> crontab -l
01 0 * * * /usr/bin/nmon -fTNWLAd^ -m /var/nmon -s30 -c2880 > /dev/null 2>&1

ps, pb memory per process example

root@prod /var/nmon> crontab -l
0,10,20,30,40,50 * * * * /root/scripts/collect_high_memory.sh > /dev/null 2>&1
5,15,25,35,45,55 * * * * /root/scripts/collect_high_memory.sh > /dev/null 2>&1
root@prod /var/nmon> cat /root/scripts/collect_high_memory.sh
#!/bin/ksh93
#set -x
#############################################
#@(#) performance collector
#############################################
# version 1.0 07-2023 collect perf per process
#############################################

dir=`dirname $0`
. $dir/.env

LOGPATH=/var/nmon

NUM=`date +%Y%m%d%H%M%S`
DAY=`date +%Y%m%d`

HN=$(echo $HOSTNAME | sed 's/\-//g' | sed 's/_//g')

desc=proc_per_mem
logname=$LOGPATH/${desc}_${HN}_${DAY}.csv


ps -efo user,pid,ppid,vsz,pcpu,pmem,comm,args | tr '\t' ' ' | sort -k4,n | tr -s ' ' | sed 's/^\ //g' | sed "s/^/${NUM}\ /" | sed 's/\ /;/' | sed 's/\ /;/' | sed 's/\ /;/' | sed 's/\ /;/' | sed 's/\ /;/' | sed 's/\ /;/' | sed 's/\ /;/' | sed 's/\ /;/' >> $logname

for file1 in $(ls $LOGPATH/${desc}_${HN}_*.csv 2>/dev/null | grep -v "_${DAY}")
do
  gzip $file1
done

#########
desc=proc_per_io
logname=$LOGPATH/${desc}_${HN}_${DAY}.csv

ps vx | sort -rn +4 | tr '\t' ' ' | tr -s ' ' | sed 's/^\ //g' | sed "s/^/${NUM}\ /" | sed 's/\ /;/g' >> $logname

for file1 in $(ls $LOGPATH/${desc}_${HN}_*.csv 2>/dev/null | grep -v "_${DAY}")
do
  gzip $file1
done
root@prod /var/nmon> cat /root/scripts/.env
# global variables for all scripts
export binpath=/root/scripts
export sn=`basename $0 | cut -d. -f1`
export HOSTNAME=`/usr/bin/hostname`
export logpath=/root/scripts/logs
export logname=$logpath/$sn.log
export configfile=$binpath/$sn.cfg
export destination="test@gmail.com"
aix/collect_perf.txt · Last modified: 2023/07/26 09:54 by manu