Edit: Some links no longer work.
Originally posted July 9, 2013 on AIXchange
Here’s another script from Dean Roswell. This one is for getting NPIV information from VIO servers. If you’re not sure how to set up ssh password-free login for your VIOS, read this. The same document is also referenced in last month’s post featuring Dean’s script that displays information about the frames that are managed by your HMC.
Here’s the latest version of this script. I will ask Dean to post in comments when he makes changes to the tools.
#!/bin/ksh
# Created by Dean Rowswell, IBM, May 31, 2013
# List Virtual and Physical Fibre Channel info for NPIV environments
#
# Assumption:
# Password-less ssh must be setup from this system to the Virtual
I/O Server(s)
VIOS_LIST=”vios1 vios2″
VIOS_USER=”padmin”
VER=”1.0″
# Parameter checks
if [ ${#*} -ne 0 ]
then
while getopts :vVh:u: PARMS
do
case $PARMS in
v|V) echo “This is get_lpar_fcinfo version:
$VER” ; exit ;;
h) VIOS_LIST=`echo $OPTARG | tr ‘,’ ‘ ‘` ;;
u) VIOS_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 VIOS hostname(s) or IP
            address(es) COMMA SEPARATED to use”
                                            echo “\t-u VIOS userid to use (only
            required if padmin not used)\n”
                            echo “EXAMPLE: get_lpar_fcinfo -h vios1,vios2\n”
                                            exit ;;
                            esac
                    done
            fi
            printf “%-12s %-10s %-27s %-5s %-20s %-12s %-5s %-6s %-6s %-27s\n”
            VIOS VFCHOST# VIOS_SLOT LPAR# LPAR_NAME STATUS PORTS PHYS VIRT
            LPAR_SLOT
            Get_Info_From_VIOS () {
            for VIOS in ${VIOS_LIST}
            do
                ssh ${VIOS_USER}@${VIOS} ioscli ioslevel >/dev/null 2>/dev/null
                if [ $? -ne 0 ]
                then
                    echo “Password-less SSH access to VIOS ${VIOS} with user
            ${VIOS_USER} is not setup\n”
                    continue
                fi
                ssh ${VIOS_USER}@${VIOS} “ioscli lsmap -all -npiv -fmt :” | awk -v
            VIOS=”$VIOS” -F: ‘{printf “%-12s %-10s %-27s %-5d %-20s %-12s %-5d
            %-6s %-6s %-27s\n”, VIOS,$1,$2,$3,$4,$6,$9,$7,$11,$12}’
            done
            }
            Get_Info_From_VIOS | sort -k4
If you’re interested, download the (sanitized) output I saw from a test machine below:
If you test it out, leave a comment to let me know how it worked and/or if you find it useful in your environment.
Note: Now AIX news and information is available to you on the go. IBM Systems Magazine, Power Systems edition, just launched an app for the Apple iPad.