One of the points of neglect I notice in systems management quite often is that many system administrators do not monitor the actual utilization of shared processor pools once they create one mainly due to the difficulty of being able to see the utilization quickly. You can easily generate the stats required via running a few commands via ssh against the HMC, you should also ensure you have utilization data collection enabled, this can be enabled by running the below command on your HMC you want to collect the data on (this will enable per minute processor utilization collection).

chlparutil -r config -s 60

Note: This will require authorized keys to be setup to function correctly due to the promptless nature of the ssh commands in the script. To setup keys simply run mkauthkeys -a "<contents of your pub ssh key>" on the HMC to add your key to the list of authorized keys.

The below script works on AIX, Linux, as well as Mac OS (provided you have tac installed and update the path accordingly in the script). It CANNOT be run from the HMC directly. Also note, if you have gaps in data the results from this script or the cycle counters reset, the results can be off for that particular time interval, but this will definitely provide a much quicker/easier look at the pool utilization. It will generate a csv file in your current working directory for every managed system and pool with a timestamp (based on HMC time) and the pool utilization percentage.

#!/bin/sh
################################################################################
# get_pool_util.sh
################################################################################
# Script Version: 1.01
# Date: 14/06/2019
# Author: Navdeep Dhaliwal
################################################################################

UTIL_NUM_DAYS=30

function logMsg() {
  local LEVEL="${1}"
  local MSG="${2}"
  printf "$(date +%Y-%m-%d' '%H:%M:%S) - [${LEVEL}] - ${MSG}\n"
}

function logError() {
  printf "$(date +%Y-%m-%d' '%H:%M:%S) - [ERROR] - ${1}\n" 1>&2
}

function logInfo() {
  logMsg "INFORMATION" "${1}"
}

function showUsage() {
  printf "Usage: $(basename $0) <flags> <HMC_IP/Hostname>\n"
  printf "Optional flags:\n"
  printf "	-d            - Number of days to pull utilization data for (default 30)\n"
  exit 1
}

while getopts "d:" Option; do
  case ${Option} in
  d) UTIL_NUM_DAYS=${OPTARG} ;;
  h) showUsage ;;
  *) showUsage ;;
  esac
done

shift $((OPTIND - 1))

if [[ $# -ne 1 ]]
then
  showUsage
fi

HMCIP=${1}

SYSTEMS=`/usr/bin/ssh -oBatchMode=yes -nq ${HMCIP} "lssyscfg -r sys -F type_model*serial_num"`
if [[ $? -ne 0 ]]
then
  logError "Could not connect to ${HMCIP}. Please verify you can connect to the HMC using \"ssh ${HMCIP}\""
  exit 255
fi

logInfo "The following managed systems were detected on ${HMCIP}:\n${SYSTEMS}"

for CURRSYS in ${SYSTEMS}
do
  POOL_IDS=`ssh -nq ${HMCIP} lshwres -r procpool -m \"${CURRSYS}\" -F shared_proc_pool_id`
  for POOL_ID in ${POOL_IDS}
  do
    logInfo "Processing utilization data for ${CURRSYS} Shared Processor Pool ${POOL_ID}"
    ssh -oBatchMode=yes -nq ${HMCIP} lslparutil -r procpool --filter \"event_types=sample,pools=${POOL_ID}\" -m \"${CURRSYS}\" -d ${UTIL_NUM_DAYS} \
    -F time,utilized_pool_cycles,total_pool_cycles  | tac \
    | awk -F, '{
      if(NR>1) {
        if ($1 != "") {
          printf ("%s,%0.0f,%0.0f,%0.2f\n",$1,$2-last_utilized,$3-last_total,(($2-last_utilized)/($3-last_total))*100)
        }
      } else {
        print "Time,Utilized Pool Cycles,Total Pool Cycles,Percentage Utilized"}} {last_utilized=$2;last_total=$3
      }' > ${CURRSYS}-Pool-${POOL_ID}.csv
      if [[ $? -ne 0 ]]
      then
        logError "An error occurred obtaining utilization data for ${CURRSYS}"
      else
        logInfo "Generated ${CURRSYS}-Pool-${POOL_ID}.csv in current working directory."
      fi
  done
done

1 Comment

Harjinder · February 19, 2020 at 3:26 pm

Exactly what I was looking for. thanks mate

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *