
#!/bin/sh
## chk_filers.sh
#@ Maarten.deBoer@atos.net, xxyyzz, 161216
#= Check filer connectivity via management-port
PGM="`basename $0|cut -d\. -f1`"
VER="0.2"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
FILERS="${HOME}/etc/filers"
SSH="/usr/bin/ssh -n"
MAIL=1
MAILTO="maarten.deboer@atos.net"

echo "`date` ${PGM} v${VER} Start."|tee -a ${LOG} ${TMP}
echo "Connections to : "|tee -a ${TMP}
for FILER in `cat $FILERS | grep -v \^#`
do
  echo -n "${FILER} ... "|tee -a ${TMP}
  HN="`${SSH} ${FILER} hostname`"
  if [ "${FILER}" = "${HN}" ]; then
    echo "${HN} OK" | tee -a ${TMP}
  else
    echo "${HN} NOTok (${FILER})" | tee -a ${TMP}
  fi
done
if [ ${MAIL} ]; then
  cat ${TMP}|mailx -s "[${PGM} v${VER}]" ${MAILTO}
  echo "  Mailed to ${MAILTO}"|tee -a ${LOG}
fi

cat ${TMP}

rm ${TMP}
echo "`date` End." | tee -a ${LOG}
exit 0

