Customer requested output for all HBA controllers of the ESXi hosts. Because ESXi is used we decided to do generate this output through the vMA appliance.

Here is how we did this:

* optional *
$ ssh vi-admin@vMA.appliance
$ vifp addserver ESXi_Host
$ vifp listservers

output:
host1.environment   ESXi
host2.environment   ESXi
vCenter.environment  vCenter
* optional *

The above was just to show how we connect to the vMA, add an ESXi host as a target and display all hosts that are listed.

Now the script that I used is based on a script originally created by William Lam. I liked this script mainly because it used an input file for the hosts and showed me how to loop through this therefore I modified it slightly to the following end-result:

#!/bin/bash
if [ $# -ne 2 ]; then
echo “$0 [VCENTER_SERVER] [HOST_INPUT_FILE]“
exit 1
fi
VCENTER_HOST=$1
HOSTLIST=$2
source /opt/vmware/vma/bin/vifptarget -s ${VCENTER_HOST} > /dev/null 2>&1
if [ $? -eq 0 ]; then
IFS=$’\n’
for VIHOST in $(cat ${HOSTLIST});
do
echo “Rescan HBA for Host: ${VIHOST}”
/usr/bin/esxcfg-rescan -h ${VIHOST} vmhba2
/usr/bin/esxcfg-rescan -h ${VIHOST} vmhba3
echo “Generating output for Host: ${VIHOST}”
/usr/bin/vicfg-mpath -h ${VIHOST} -L > /tmp/output-${VIHOST}.txt
echo
done
unset IFS
else
echo “Unable to intialize vi-fastpass on target ${FIST_HOST}”
fi

The script is run as follows: ./HBArescan vCenter input.csv. Output given can be edited with for instance Excel and will display all HBA information.
-Ray