Edit: Some links no longer work.
Originally posted June 4, 2013 on AIXchange
Dean Roswell sent over another handy script that you should add to your virtual bag of tricks. Dean’s latest script (version 1.4 as of this writing) provides a quick list of information about the HMC and the LPARs running on it.First, set up your ssh client so you can connect without a password between your HMC and the LPAR you’ll run the script on.
If you aren’t sure how to set this up, you should be able to find help through a web search. I created my id_rsa.pub file after viewing this document. It lists these steps:
            To enable scripts to run unattended between an SSH client and an HMC, do the following:
Open the Remote Command Execution task from the HMC Management work pane.
From the Remote Command Execution window, select Enable remote command execution using the ssh facility.
Create an HMC user with one of the following roles:
Super administrator (hmcsuperadmin)
Service representative (hmcservicerep)
On the client’s operating system, run the SSH protocol key generator.
To run the SSH protocol key generator, do the following:
To store the keys, create a directory named $HOME/.ssh (either RSA or DSA keys can be used).
To generate public and private keys, run the following command: ssh-keygen -t rsa
The following files are created in the $HOME/.ssh directory:
private key: id_rsa
public key: id_rsa.pub
The write bits for both group and other are turned off. Ensure that the private key has a permission of 600.
Once this was complete, I copied over my file using:
            mykey=’cat $HOME/.ssh/id_rsa.pub’
            ssh hmc.domain.com -l hmcuser mkauthkeys -a \”$mykey\”
Then I copied over Dean’s script, making sure it was executable. I changed the HMC_LIST variable to match an HMC in my environment:
#!/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
# 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=”hmc1 hmc2″
HMC_USER=”hscroot”
VER=”1.4″
# Parameter checks
if [ ${#*} -ne 0 ]
then
while getopts :vVh:u: PARMS
do
case $PARMS in
v|V) echo “This is get_lpar_info version: $VER” ; exit ;;
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)\n”
echo “EXAMPLE: get_lpar_info -h hmc1,hmc2\n”
exit ;;
esac
done
fi
for HMC in ${HMC_LIST}
do
ssh ${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 ${HMC_USER}@${HMC} “lshmc -v | grep -E ‘TM|SE|RM'” | sed ‘s/eserver xSeries 336 -\[//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 ${HMC_USER}@${HMC} “lssyscfg -r sys -F type_model*serial_num|sort”`
for SYSTEM in ${MANAGEDSYS}
do
echo “\nIBM POWER SYSTEM: ${SYSTEM} / SysFW Ver: \c”
ssh ${HMC_USER}@${HMC} “lslic -m ${SYSTEM} -F ecnumber:activated_level|sed ‘s/:/_/g’|cut -c 3-“|tr -s ‘\n’ ‘ ‘
ssh ${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 ${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 / ” 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 ${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 ${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 ${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 ${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 ${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 }
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 = “NA” } else { RATIO = PROC_UNITS/VIRT_PROC}
printf ” %3d %-20s %-9s %-24s %-13s %5.1f %-8s %-7s %-17s %-3d %-4.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 {print ” —————————————————————————————————————————————–” ; printf ” LPAR TOTALS %63.1f %43.2f %3d %9.2f\n”, TOTAL_MEM/1024, TOTAL_PROC_UNITS, TOTAL_VIRT_PROC, TOTAL_PROC_UNITS/TOTAL_VIRT_PROC}’
done
done
In my environment I got the following output, some of which is masked to protect the identity of the customer that allowed me to run this. Of course the output looks best in a format wide enough to support all of the columns. Here, most of the lines are wrapped. A few spaces are added so you can see the different entries.
=================================
HARDWARE MANAGEMENT CONSOLE
Hostname: HMC1 / Model: 7042-CR4
Serial: 123456B / Ver: V7R7.7.0.2
Sun Jun 2 15:23:37 CDT 2013
=================================
IBM POWER SYSTEM: 8202-E4B*12345CP / SysFW Ver: AL720_108
PROC INFO: 4.0 Installed / 4.0 Configurable / 2.9 Used / 1.1 Available
MEM INFO: 64 GB Install / 64 GB Config / 32.75 GB Used / 31.25 GB Avail / 2.25 GB SysFW / 256 MB LMB
LPAR INFO: NOTE: THE MEMORY AND PROCESSOR VALUES ARE FROM THE ACTIVE/RUNNING LPAR VALUES (NOT FROM LPAR PROFILE)
ID NAME TYPE OS_VER STATE MEM(GB) MODE PROC MODE POOL ENT VP WT ENT/VP
1 vios1 vioserver VIOS_2.2.0.10-FP-24_SP-01 Running 3.2 ded shared uncap 0 0.50 4 128 0.12
2 lpar1 aixlinux AIX_5.3_5300-12-05-1140 Running 4.2 ded shared uncap 0 0.40 4 128 0.10
3 vios2 vioserver VIOS_2.2.0.10-FP-24_SP-01 Running 4.2 ded shared uncap 0 0.40 4 128 0.10
4 vios3 vioserver VIOS_2.2.0.10-FP-24_SP-01 Running 4.2 ded shared uncap 0 0.40 4 128 0.10
5 nim aixlinux Unknown Running 4.2 ded shared uncap 0 0.40 4 128 0.10
6 db2 aixlinux Unknown Running 4.2 ded shared uncap 0 0.40 4 128 0.10
7 lpar2 aixlinux Unknown Running 4.0 ded shared uncap 0 0.20 2 128 0.10
8 vios3 aixlinux Unknown Running 2.0 ded shared uncap 0 0.20 2 128 0.10
—————————————————————————————————————————————–
LPAR TOTALS 30.5 2.90 28 0.10
IBM POWER SYSTEM: 9111-520*12346A / SysFW Ver: SF240_415
PROC INFO: 2.0 Installed / 2.0 Configurable / 2 Used / 0.0 Available
MEM INFO: 4 GB Install / 4 GB Config / 4 GB Used / 0 GB Avail / 0.34375 GB SysFW / 16 MB LMB
LPAR INFO: NOTE: THE MEMORY AND PROCESSOR VALUES ARE FROM THE ACTIVE/RUNNING LPAR VALUES (NOT FROM LPAR PROFILE)
ID NAME TYPE OS_VER STATE MEM(GB) MODE PROC MODE POOL ENT VP WT ENT/VP
1 lpar1 aixlinux Unknown Not_Activated 0.0 ded ded share_idle_procs 0 0.00 0 0 0.00
2 demo aixlinux Unknown Not_Activated 0.0 ded ded share_idle_procs 0 0.00 0 0 0.00
3 test aixlinux Unknown Not_Activated 0.0 ded ded share_idle_procs 0 0.00 0 0 0.00
4 lpar2 aixlinux Unknown Running 3.7 ded ded share_idle_procs 0 0.00 2 0 0.00
5 lpar3 aixlinux Unknown Not_Activated 0.0 ded shared uncap 0 0.00 0 0 0.00
6 lpar4 aixlinux Unknown Not_Activated 0.0 ded shared uncap 0 0.00 0 0 0.00
—————————————————————————————————————————————–
LPAR TOTALSÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3.7Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0.00Â Â Â 2Â Â Â Â Â Â 0.00
If you want to see how both scripts look with the proper spacing, check out the attached PDFs below.
Let me know how the script works for you. And many thanks to Dean for giving permission to post it here.