
#!/bin/sh
# File 	: fsod_environment_show.sh
# By	: Maarten.deBoer@Atos.net, 260310
# Subject	: Script to gather
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
SSH="/usr/bin/ssh -n"
MAILTO="maarten.deboer@atos.net"

CLUSTER="nlnaf102"
ASC="/tmp/${PGM}_${CLUSTER}.asc"
CMDS="${HOME}/etc/${PGM}.cmds"

if [ "${1}" != "" ]; then
  CLUSTER="${1}"
fi 

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

echo "  ASC=${ASC}"
echo "  CMDS=${CMDS}"
echo "  CLUSTER(1)=${CLUSTER}"
echo "  MAILTO=${MAILTO}"
sleep 1

if [ -f ${CMDS} ]; then
  echo "========="
  echo "Cluster : ${CLUSTER}"|tee -a ${ASC}
  cat ${CMDS}|grep -v ^#|while read LINE
  do
    echo "--------" |tee -a ${ASC}
    echo "${LINE} :" |tee -a ${ASC}
    ${SSH} ${CLUSTER} "${LINE}" | tee -a ${ASC}

  done  # LINE
fi  # 

if [ -s ${ASC} ] && [ "${MAILTO}" != "" ]; then
  date | mailx -a ${ASC} -s "NetApp/FSOD environment report for ${CLUSTER} [${PGM} v${VER}]" ${MAILTO}
  echo "  Mailed to ${MAILTO}"|tee -a ${LOG}
fi  # MAIL

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

