
#!/bin/sh
# File	: cdot_snaplock_migr_status.sh
# By	: Maarten.deBoer@Atos.net, 240304
# Subject	: Script to show / report the sttaus of SnapLock migration process
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
TMP="/tmp/${PGM}.$$"
ASC="/tmp/${PGM}.asc"
LOG="${HOME}/log/${PGM}.log"
SSH="/usr/bin/ssh -n"
HOSTNAME=`hostname |cut -d\. -f1`

CLUSTERS="${HOME}/etc/clusters"
MAILTO="maarten.deboer@atos.net"

echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}
touch ${TMP}

for CLUSTER in `cat ${CLUSTERS}|grep -v ^#|grep -E "nlnaf10[67]" `
do
  echo "  ${CLUSTER}"

  echo "Vservers (${CLUSTER}):" |tee -a ${TMP}
  ${SSH} ${CLUSTER} "vserver show -field vserver,operational-state"|grep -v "${CLUSTER}"|tee -a ${TMP}
  echo "SnapMirror destinations (${CLUSTER}):" |tee -a ${TMP}
  ${SSH} ${CLUSTER} "snapmirror list-destinations -field source-path,destination-path, policy-type,status,type" |tee -a ${TMP}

done  # for

if [ "${MAILTO}" != "" ]; then
  cp ${TMP} ${ASC}
  echo "For status, see attachment."| mailx -a ${ASC} -s ":${HOSTNAME} SnapLock status [${PGM} v${VER}]" ${MAILTO}
  echo "  Mailed to ${MAILTO}"|tee -a ${LOG}
fi


rm ${TMP}
echo "`date` ${PGM} v${VER} finished."|tee -a ${LOG}
exit 0

