
#!/bin/sh
# File	: cdot_chk_home-port.sh
# By	: Maarten.deBoer@Atos.net, 160226
# Subject	: Script to check (at cDOT) if LIFs are at home port
#
PGM="`basename $0|cut -d\. -f1`"
VER="0.1"
TMP="${PGM}.$$"
SSH="/usr/bin/ssh -n"
CLUSTERS="${HOME}/etc/clusters"

PINGHOSTS="${HOME}/etc/${PGM}.hosts"

ETCFILE="${HOME}/etc/${PGM}.conf"

cp /dev/null ${ETCFILE}

for CLUSTER in `cat ${CLUSTERS}|grep -v ^#|grep nlnaf10[01]` 
do
  echo "${CLUSTER} ..."
#  ${SSH} ${CLUSTER} "set -showseparator \";\" ; net int show -is-home false -fields vserver,home-node,curr-node,curr-port ,home-port,is-home"
  ${SSH} ${CLUSTER} "set -showseparator \" \" ; net int show -is-home false -fields vserver,lif,is-home"|grep false|awk '{print $1,$2}'|while read VSERVER LIF REST
  do
    PINGHOST="`grep ${VSERVER} ${PINGHOSTS}|awk -F\; '{print $2}'`"
    echo "${VSERVER};${LIF};${PINGHOST};"|tee -a ${ETCFILE}

  done  # while
done   # for

exit 0

