AIX: Performance monitoring with Nagios

Some articles here will describe how to monitor the CPU performance of an LPAR and the implementation of some checks within Nagios.

check_aix_cpu_pool_usage.sh

#!/usr/bin/ksh

# check how many physical cpus are consumet via lparstat
# according to a definition set by the app – owner
# the cpu usage < 2 CPUs left on the system will result
# in an errorcode 2
# for nagios to be critical and alerted

crit=2
cpu_usage=`lparstat 1 5 | awk ‘{print $8}’ | tail -5`
cpu_usage=`echo $cpu_usage | sed ‘s/ /+/g’`
cpu_usage=`echo $cpu_usage | sed ‘s/^/(/g’`
cpu_usage=`echo $cpu_usage | sed ‘s/$/)/g’`

summary=`echo $cpu_usage | bc`
summary=`echo “scale=2\n”$summary/5 | bc`

if [ $summary -lt 2 ]; then
echo “only $summary cpus available on p570-tower|’CPU’=$summary;2;2;0;20”
exit 2
else
echo “currently $summary cpus available on p570-tower|’CPU’=$summary;2;2;0;20”
exit 0
fi

 

check_aix_cpu_vp_idle.sh

#!/usr/bin/ksh

# check VCPU usage in percent
# according to a definition set by the app – owner
# the virtual cpu  usage > 80% CPUs left on the system will result
# in an errorcode 2
# for nagios to be critical and alerted

NUM_VCPUS=`lsdev -Cc processor|wc -l|awk ‘{print $1}’`
PHYSC=`sar 1 5|tail -1|awk ‘{print $6}’`

PCTUSED=`echo “scale=2\n ${PHYSC}*100/${NUM_VCPUS}”|bc`

if [ $PCTUSED -gt 80 ]; then
echo “Total CPU usage exceeds $PCTUSED % on `hostname`|’VCPU’=$PCTUSED;70;80;0;100”
exit 2
else
echo “Total CPU usage is $PCTUSED % on `hostname`|’VCPU’=$PCTUSED;70;80;0;100”
exit 0
fi

check_aix_entitled_cpu.sh

!/usr/bin/ksh

# check how many physical cpus are consumet via lparstat
# according to a definition set by the app – owner
# the cpu usage < 2 CPUs left on the system will result
# in an errorcode 2
# for nagios to be critical and alerted

crit=2
cpu_usage=`lparstat 1 5 | awk ‘{print $6}’ | tail -5`
cpu_usage=`echo $cpu_usage | sed ‘s/ /+/g’`
cpu_usage=`echo $cpu_usage | sed ‘s/^/(/g’`
cpu_usage=`echo $cpu_usage | sed ‘s/$/)/g’`

summary=`echo $cpu_usage | bc`
summary=`echo “scale=2\n”$summary/5 | bc`

if [ $summary -gt 100 ]; then
echo “$summary% entitled CPUs are being used on `hostname`|’CPU’=$summary;100;120;0;500”
exit 2
else
echo “currently $summary entitled CPUs are being used on `hostname`|’CPU’=$summary;100;120;0;500”
exit 0
fi

Advertisements
This entry was posted in aix, Nagios and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s