
#!/bin/sh
# File	: chk_netapp-system.sh
# By	: Maarten.deBoer@Atos.net, 240514
# Subject	: Script to check NetApp system or error (Not Normal)
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
ASC="/tmp/${PGM}.asc"
SSH="/usr/bin/ssh -n"

MAILTO="maarten.deboer@atos.net"

CLUSTERS="${HOME}/etc/clusters"

echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}
echo "  CLUSTERS=${CLUSTERS}"
sleep 1

touch ${TMP}

cat ${CLUSTERS}|grep -v ^#|while read CLUSTER
do
  echo "  CLUSTER=${CLUSTER}"|tee -a ${TMP}
  ${SSH} ${CLUSTER} 'storage shelf show -op-status !normal'|tee -a ${TMP}
  ${SSH} ${CLUSTER} 'disk show -container-type broken -field container-type,disk'|tee -a ${TMP}

  ${SSH} ${CLUSTER} 'system node environment sensors show -state !normal -field node, name,state'|tee -a ${TMP}


done  # CLUSTER

if [ -s ${TMP} ] && [ "${MAILTO}" != "" ]; then
  cp ${TMP} ${ASC}
  date | mailx -a ${ASC} -s "Check NetApp-systems [${PGM} v${VER}]" "${MAILTO}" 
fi  # MAILTO

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

