Report() {
for hmc in {abr-hmc,msp-hmc,den-hmc}; do
ssh "$hmc" 'for cec in $(lssyscfg -r sys -F name | sort); do # SSH into each HMC and get the list of CECs.
CPU="$(lshwres -m $cec -r proc --level sys -F configurable_sys_proc_units)" # Get total configurable CPU units.
Avail_CPU="$(lshwres -m $cec -r proc --level sys -F curr_avail_sys_proc_units)" # Get currently available CPU units.
MEM="$(lshwres -m $cec -r mem --level sys -F configurable_sys_mem)" # Get total configurable memory.
Avail_MEM="$(lshwres -m $cec -r mem --level sys -F curr_avail_sys_mem)" # Get currently available memory.
echo "$cec $CPU $Avail_CPU $MEM $Avail_MEM" # Output the CEC name, total and available CPU and memory.
done'
done
}
if [ -t 0 ]; then
hfmt="%-35s%15s%15s%15s%15s%15s%15s\n"
fmt="%-35s%15s%15s%15.1f%15.1f%15.1f%15.1f\n"
else
hfmt="%s,%s,%s,%s,%s,%s,%s\n"
fmt="%s,%s,%s,%.1f,%.1f,%.1f,%.1f\n"
fi
printf "$hfmt" "CEC" "CPU" "Avail CPU" "CPU % Used" "MEM (GB)" "Avail MEM" "MEM % Used"
Report | awk -v fmt="$fmt" '{
# Calculate CPU and memory usage percentages and print the formatted output.
printf fmt, $1, $2, $3, ($2-$3)/$2*100, $4/1024, $5/1024, ($4-$5)/$4*100
}' | sort | uniq