#!/bin/sh # # emcprint # # This script prints the dir-con-lun for each subdisk # that has an emc name. It's printed in 'vxprint -htr' # format for easy viewing. # # Author: Todd Stansell # # $Id: emcprint,v 1.6 2001-08-13 16:15:27-07 todd Exp $ # PATH=/bin:/usr/sbin MATRIX=/opt/scripts/matrix vxargs="-htr" base=`basename $0` # # show usage and exit with non-zero status # usage() { echo "usage: $base [-help] " echo " if no arguments, then we use $vxargs" exit 1 } # # parse arguments...show usage if -help or -? only, since # the most likely option will be -htr # case "$@" in -help|-?) usage ;; *) [ "$@" ] && vxargs="$@" ;; esac # # make sure the arguments are valid # if vxprint $vxargs >/dev/null ; then # # print each line in vxprint format. # vxprint $vxargs | nawk ' # # load the emc dir-con-lun number for each emc lun # and then append it to the vxprint line # BEGIN { # # c[] holds the width of each column # for the vxprint output. set the size to 0 to # omit that column from the output. # c[1]=2;c[2]=12;c[3]=10;c[4]=9;c[5]=8; c[6]=8;c[7]=11;c[8]=9;c[9]=4;c[10]=8; c[5]=0;c[9]=0; # # emc[] holds the dir-con-lun info for each device # while (getline <"'$MATRIX'") { emc[$1] = $3 getline <"'$MATRIX'" } close "'$MATRIX'" } # # for each line in vxprint output... # { fixlen=0;line=""; lun=""; # initialize for (i=1;i<=NF;i++) space[i]="" # initialize if ($0 ~ /^sd.*emc/) lun=emc[substr($4,4)] # sd entry else if ($0 ~ /^dm.*emc/) lun=emc[substr($2,4)] # dm entry else if ($0 ~ /^SD|^DM/) lun="DIR-C-L" # header line for (i=1;i<=NF;i++) { z=length($i)+length(line)-fixlen # z = char to end col for (l=z;l 0) line=line""space[i] # build output fixlen=fixlen+c[i]+1; } printf "%s%s\n",line,lun }' fi