Page 1 of 1

AIX Memory Utilization -- Lpar

Posted: Fri Mar 03, 2017 1:47 pm
by raamardhani7
Hi Team,

I would need your help in getting the CPU utilization of lpar. as per the script, threshold for warning and critical will be different for server to server. So wanted to have this information in percentages. Is there a plugin that can help me get that information? Or attaching the script, could you please help me with this.

Code: Select all

#!/bin/ksh93
#
# check_lpar_physc_cpu.sh
#
# This plugin checks LPAR Physical CPU usage
# Author: Bratislav STOJKOVIC
# E-mail:[email protected]
# Version: 0.1
# Last Modified: October 2013

PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo 'Revision: 0.1'`
. $PROGPATH/utils.sh


print_usage() {
        echo "Usage: $PROGNAME -w <warning_thr> -c <critical_thr>"
}

print_revision() {
        echo $PROGNAME $REVISION
        echo ""
        echo "This plugin checks LPAR Physical CPU usage"
        echo ""
        exit 0
}

if [ $# -eq 1 ] && ([ "$1" == "-h" ] || [ "$1" == "--help" ]); then
        print_usage
        exit $STATE_UNKNOWN
elif [ $# -lt 4 ]; then
        print_usage
        exit $STATE_UNKNOWN
fi

while test -n "$1"; do
case "$1" in
        --help)
                print_usage
                exit 0
                ;;
        -h)
                print_usage
                exit 0
                ;;
        -V)
                print_revision $PROGNAME $REVISION
                exit 0
                ;;
        -w)
            WARNING=$2
            shift
            ;;
        -c)
            CRITICAL=$2
            shift
            ;;
        *)
            echo "Unknown argument: $1"
            print_usage
            exit $STATE_UNKNOWN
            ;;
esac
shift
done

LPAR_PHYSC=``
/usr/bin/lparstat 1 1 | awk '{print $5}'| tail -1
if (( $LPAR_PHYSC > $CRITICAL )); then
   echo "CRITICAL: $LPAR_PHYSC processor cores are busy.|Cores=$LPAR_PHYSC;$WARNING;$CRITICAL"
   exit $STATE_CRITICAL
fi
if (( $LPAR_PHYSC > $WARNING )); then
   echo "WARNING: $LPAR_PHYSC processor cores are busy.|Cores=$LPAR_PHYSC;$WARNING;$CRITICAL"
   exit $LPAR_PHYSC
else
   echo "OK: $LPAR_PHYSC processor cores are busy.|Cores=$LPAR_PHYSC;$WARNING;$CRITICAL"
   exit $STATE_OK
fi

Re: AIX Memory Utilization -- Lpar

Posted: Fri Mar 03, 2017 3:18 pm
by mcapra
Can you share what this script outputs currently? I'm not super familiar with kornshell, but it should be some simple math that needs to be done on $LPAR_PHYSC before it gets added as performance data.

Re: AIX Memory Utilization -- Lpar

Posted: Fri Mar 03, 2017 4:22 pm
by raamardhani7
mcapra wrote:Can you share what this script outputs currently? I'm not super familiar with kornshell, but it should be some simple math that needs to be done on $LPAR_PHYSC before it gets added as performance data.

Hi Team,

Updated the details.

Code: Select all

 ./check_lpar_cpu -w 80 -c 90
OK: 0.03 processor cores are busy.|Cores=0.03;80;90

Code: Select all

./check_lpar_cpu -w 0.2 -c 03
OK: 0.02 processor cores are busy.|Cores=0.02;0.2;03

Code: Select all

/usr/bin/lparstat 1 1 | awk '{print $5}'| tail -1
0.02

Code: Select all

./check_lpar_cpu -w 0.001 -c 0.2
WARNING: 0.02 processor cores are busy.|Cores=0.02;0.001;0.2

Code: Select all

/usr/bin/lparstat 1 1 | awk '{print $5}'

smt=4

physc
-----
0.01
Please advise.

Re: AIX Memory Utilization -- Lpar

Posted: Mon Mar 06, 2017 11:28 am
by mcapra
Around lines 52, 56, and 70, you could probably multiply these respective variables by 100:

Code: Select all

52      WARNING=$2
56      CRITICAL=$2
70      #new line to multiply $LPAR_PHYSC
Or, if you wanted your thresholds to be whole-number percentages, you could just modify line 70. If you're interested in having us modify this plugin for you, please contact our sales department regarding custom development.