Blog
AIXchange

Categories

« VIOS Installation via GUI | Main | Sizing Power Systems »

June 04, 2013

Comments

If anyone experiences issues with older HMC's (ie. version 6) or if a Power server has no running LPAR's then e-mail me at dean.rowswell@ca.ibm.com for the updated script to deal with these 2 situations.

Here's the latest version 1.11. If it doesn't copy/paste properly then email me at dean.rowswell@ca.ibm.com

$ cat get_lpar_info
#!/bin/ksh
# Created by Dean Rowswell, IBM, March 20, 2013
# Modified by Dean Rowswell, IBM, April 24, 2013
# Calculate the USED Processor and Memory values
# Modified by Dean Rowswell, IBM, May 7, 2013 - Version 1.0
# Display Memory and Processor config for each LPAR
# Accept parameters for the HMC(s) and HMC user to use
# Correctly determine HMC information for Version 7.3.5
# Ignore mem_mode for POWER5 servers
# Modified by Dean Rowswell, IBM, May 9, 2013 - Version 1.1
# Calculate the LPAR totals for Memory, Processor Entitlement and Virtual Processors
# Modified by Dean Rowswell, IBM, May 9, 2013 - Version 1.2
# Skip any HMC which does not have password-less ssh setup
# Modified by Dean Rowswell, IBM, May 10, 2013 - Version 1.3
# Remove the G in the LPAR memory column and add GB label to header
# Calculate the Entitlement to Virtual Processor ratio for each LPAR and overall system
# Modified by Dean Rowswell, IBM, May 10, 2013 - Version 1.4
# Fixed bug with divide by zero error if LPAR is in the Not_Activated state and the Virtual Processor value is 0
# Modified by Dean Rowswell, IBM, May 14, 2013 - Version 1.5
# Fixed bug with divide by zero error if there are no Running LPARs on the Power server + parse older HMC info correctly
# Modified by Dean Rowswell, IBM, May 24, 2013 - Version 1.6
# Correctly determine server firmware level using HMC version 6
# Modified by Dean Rowswell, IBM, July 10, 2013 - Version 1.7
# Increase column width for LPAR entitlement + calculate Power server system firmware percentage
# Modified by Dean Rowswell, IBM, September 16, 2013 - Version 1.8
# Add a -f flag to ignore the system firmware check which will allow this script to run faster
# Modified by Dean Rowswell, IBM, December 13, 2013 - Version 1.9
# Include the customized name of the Managed System in the output
# Modified by Dean Rowswell, IBM, February 20, 2014 - Version 1.10
# Add the -q flag to the ssh commands to suppress the HMC banner
# Modified by Dean Rowswell, IBM, May 20, 2014 - Version 1.11
# Calculate LPAR counts for each Power server
# List HMC, POWER server, and LPAR info using the HMC
#
# Assumption:
# Password-less ssh must be setup from this system to the HMC(s) in the HMC_LIST variable

HMC_LIST="hmc01 hmc02"
HMC_USER="hscroot"

VER="1.11"

# Parameter checks
if [ ${#*} -ne 0 ]
then
while getopts :vVfh:u: PARMS
do
case $PARMS in
v|V) echo "This is get_lpar_info version: $VER" ; exit ;;
f) SKIP_FW=1 ;;
h) HMC_LIST=`echo $OPTARG | tr ',' ' '` ;;
u) HMC_USER=${OPTARG} ;;
?) echo "\nUSAGE:\t$0 [ -v, -V, -h, -u ]"
echo "\t-v or -V will print out the version and exit"
echo "\t-h HMC hostname(s) or IP address(es) COMMA SEPARATED to use"
echo "\t-u HMC userid to use (only required if hscroot not used)"
echo "\t-f will skip the firmware check to speed up runtime\n"
echo "EXAMPLE: get_lpar_info -h hmc1,hmc2\n"
exit ;;
esac
done
fi

for HMC in ${HMC_LIST}
do
ssh -q ${HMC_USER}@${HMC} date >/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
echo "\nPassword-less SSH access to HMC ${HMC} with user ${HMC_USER} is not setup\n"
continue
fi
echo "\n===================================="
echo "HARDWARE MANAGEMENT CONSOLE"
echo "Hostname: ${HMC} / \c"
ssh -q ${HMC_USER}@${HMC} "lshmc -v | grep -E 'TM|SE|RM'" | sed 's/eserver xSeries 33[56] -\[//g' | sed 's/]-//g' | tr -s '\n' ' ' | awk '
{MODEL = $2 ; SERIAL = $4 ; VERSION = $6};
END { print "Model: " MODEL "\nSerial: " SERIAL " / Ver: " VERSION}'
echo "`date`"
echo "===================================="
MANAGEDSYS=`ssh -q ${HMC_USER}@${HMC} "lssyscfg -r sys -F type_model*serial_num|sort"`

for SYSTEM in ${MANAGEDSYS}
do
if [ ${SKIP_FW:=0} -eq 1 ]
then
FULLSYSNAME=`ssh -q ${HMC_USER}@${HMC} "lssyscfg -r sys -m ${SYSTEM} -F name*type_model*serial_num | sed 's/*/ \/ /g'"`
echo "\nIBM POWER SYSTEM: ${FULLSYSNAME}\c"
else
FULLSYSNAME=`ssh -q ${HMC_USER}@${HMC} "lssyscfg -r sys -m ${SYSTEM} -F name*type_model*serial_num | sed 's/*/ \/ /g'"`
echo "\nIBM POWER SYSTEM: ${FULLSYSNAME} / System Firmware Version: \c"
ssh -q ${HMC_USER}@${HMC} "lslic -m ${SYSTEM} -F ecnumber:activated_level" >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
ssh -q ${HMC_USER}@${HMC} "lslic -m ${SYSTEM} -F ecnumber:activated_level|sed 's/:/_/g'|cut -c 3-"|tr -s '\n' ' '
else
ssh -q ${HMC_USER}@${HMC} "lslic -m ${SYSTEM} -F ecnumber:activated_level -t sys|sed 's/:/_/g'|cut -c 3-"|tr -s '\n' ' '
fi
fi

ssh -q ${HMC_USER}@${HMC} "lshwres -m ${SYSTEM} -r proc --level sys -F installed_sys_proc_units:configurable_sys_proc_units:curr_avail_sys_proc_units"|awk -F: '
{INSTALL = $1 ; CONFIG = $2 ; AVAIL = $3};
END { print "\n PROC INFO:\t" INSTALL " Installed / " CONFIG " Configurable / " CONFIG-AVAIL " Used / " AVAIL " Available "}'

ssh -q ${HMC_USER}@${HMC} "lshwres -m ${SYSTEM} -r mem --level sys -F installed_sys_mem:configurable_sys_mem:curr_avail_sys_mem:sys_firmware_mem:mem_region_size" |awk -F: '
{INSTALL = $1 ; CONFIG = $2 ; AVAIL = $3 ; SYSFW = $4 ; LMB = $5};
END { print " MEM INFO:\t" INSTALL/1024 " GB Install / " CONFIG/1024 " GB Config / " (CONFIG-AVAIL)/1024 " GB Used / " AVAIL/1024 " GB Avail / " SYSFW/1024 " GB SysFW (" SYSFW/CONFIG*100 " %) / " LMB " MB LMB"}'

echo " LPAR INFO: NOTE: THE MEMORY AND PROCESSOR VALUES ARE FROM THE ACTIVE/RUNNING LPAR VALUES (NOT FROM LPAR PROFILE)\n ID NAME TYPE OS_VER STATE MEM(GB) MODE PROC MODE POOL ENT VP WT ENT/VP"

Get_LPAR_Info() {
LPARS=`ssh -q ${HMC_USER}@${HMC} "lssyscfg -r lpar -m ${SYSTEM} -F lpar_id:name:lpar_env:os_version:state|sed 's/ /_/g'|sort -n"`
for LPAR in ${LPARS}
do
printf " %-24s\n" ${LPAR}
done

PROC=`ssh -q ${HMC_USER}@${HMC} "lshwres -m ${SYSTEM} -r proc --level lpar -F lpar_id:curr_proc_mode:curr_sharing_mode:curr_shared_proc_pool_id:run_proc_units:run_procs:run_uncap_weight|sort -n"`
for LPAR in ${PROC}
do
printf " %-24s\n" ${LPAR}
done

ssh -q ${HMC_USER}@${HMC} "lshwres -m ${SYSTEM} -r mem --level lpar -F lpar_id:mem_mode:run_mem" >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
MEM=`ssh -q ${HMC_USER}@${HMC} "lshwres -m ${SYSTEM} -r mem --level lpar -F lpar_id:mem_mode:run_mem|sort -n"`
for LPAR in ${MEM}
do
printf " %-24s\n" ${LPAR}
done
else
MEM=`ssh -q ${HMC_USER}@${HMC} "lshwres -m ${SYSTEM} -r mem --level lpar -F lpar_id:run_mem|sort -n"`
for LPAR in ${MEM}
do
printf " %-24s\n" ${LPAR}
done
fi
}

Get_LPAR_Info | sort -n | awk -F: '{
if (NF == 5) { LPAR_ID=$1; LPAR_NAME=$2; OS_TYPE=$3; OS_VER=$4; STATE=$5; LPAR_COUNT +=1;
if ($3 == "aixlinux" ) { if ($5 == "Running") {AIXLINUX_RUNNING += 1} else {AIXLINUX_NOTRUNNING += 1}};
if ($3 == "vioserver") { if ($5 == "Running") {VIOS_RUNNING += 1} else {VIOS_NOTRUNNING += 1}};
if ($3 == "os400" ) { if ($5 == "Running") {OS400_RUNNING += 1} else {OS400_NOTRUNNING += 1}};
}
if (NF == 3) { MEM_MODE=$2; MEM=$3 }
if (NF == 2) { MEM_MODE="NA"; MEM=$2 }
if (NF == 7) { PROC_MODE=$2; SHARE_MODE=$3; SHARED_POOL=$4; PROC_UNITS=$5; VIRT_PROC=$6; WEIGHT=$7 }
if ((length(LPAR_ID) != 0 && length(MEM_MODE) !=0 && length(PROC_MODE) != 0)) {
if (VIRT_PROC == 0) { RATIO = 0 } else { RATIO = PROC_UNITS/VIRT_PROC }
printf " %3d %-25s %-9s %-24s %-13s %5.1f %-8s %-7s %-17s %-3d %5.2f %3d %3d %5.2f\n", LPAR_ID, LPAR_NAME, OS_TYPE, OS_VER, STATE, MEM/1024, MEM_MODE, PROC_MODE, SHARE_MODE, SHARED_POOL, PROC_UNITS, VIRT_PROC, WEIGHT, RATIO; TOTAL_MEM += MEM; TOTAL_PROC_UNITS += PROC_UNITS; TOTAL_VIRT_PROC += VIRT_PROC ; LPAR_ID=""; MEM_MODE=""; MEM=""; PROC_MODE="" }
} END { if (TOTAL_VIRT_PROC == 0) { TOTAL_RATIO = 0 } else { TOTAL_RATIO = TOTAL_PROC_UNITS/TOTAL_VIRT_PROC } ; print " ----------------------------------------------------------------------------------------------------------------------------------------------" ; printf " LPAR TOTALS %68.1f %44.2f %3d %9.2f\n COUNTS: TOTAL=%-4d / VIOS_Running=%-3d VIOS_NOT_Running=%-3d / AIXLINUX_Running=%-3d AIXLINUX_NOT_Running=%-3d / OS400_Running=%-3d OS400_NOT_Running=%-3d\n", TOTAL_MEM/1024, TOTAL_PROC_UNITS, TOTAL_VIRT_PROC, TOTAL_RATIO, LPAR_COUNT, VIOS_RUNNING, VIOS_NOTRUNNING, AIXLINUX_RUNNING, AIXLINUX_NOTRUNNING, OS400_RUNNING, OS400_NOTRUNNING}'
done
done

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.