#!/bin/sh . /usr/local/lib/vmware.sh if [ "$1" != "-h" ]; then echo "Name ID Mem(MiB) VCPUs State" fi list_vms | while read vm ; do vmname="`echo ${vm} | cut -d '|' -f 2`" vmid=`echo ${vm} | cut -d '|' -f 1` printf '%-25s %5s' ${vmname} ${vmid} vmware-vim-cmd vmsvc/get.summary ${vmid} | \ sed -n 's/^[ ]*\(powerState\|memorySizeMB\|numCpu\) = \(.*\),[ ]*$/\1 \2/p' | \ awk ' { if ($1 == "powerState") { power=substr($2, 2, length($2)-2) } else if ($1 == "memorySizeMB") { memory=$2 } else if ($1 == "numCpu") { cpus=$2 } } END { printf "%9s %5s %s\n", memory, cpus, power } ' done