
#!/bin/sh
# File	: cdot_rpt_volumes.sh
# By	: Maarten.deBoer@Atos.net, 200930
# Subject	: Script to report (cDOT) volumes into CSV-file
PGM=`basename $0|cut -d\. -f1`
VER="0.2"
SSH="/usr/bin/ssh -n"
LOG="${HOME}/log/${PGM}.log"
MAILTO="maarten.deboer@atos.net"

DATI=`date +%Y-%m-%d-%H-%M-%S`

CLUSTERS="${HOME}/etc/clusters"
CFILTER="nlnaf"
#CFILTER="nlnaf100"
CSV="/tmp/${PGM}_${CFILTER}_${DATI}.csv"

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

cat ${CLUSTERS}|grep -v ^#|grep ${CFILTER}|while read CLUSTER REST
do
  echo "${CLUSTER} ..."
  ${SSH} ${CLUSTER} "set -units MB -showseparator \";\" ; volume show -volume * -field vserver,volume,total,logical-used,is-space-reporting-logical,logical-available,is-space-enforce,logical-used-percent,min,max,autosize-grow-threshold-percent,autosize-shrink-threshold-percent,autosize-mode,used,avail,sis-space-saved,dedupe-space-saved,compression-space-saved,space-guarantee,compression-space-saved" |grep -v 'Vserver Name'|sed 's/MB//g' >> ${CSV}

done

echo " Figures are in MB" >> ${CSV}
echo "" >> ${CSV}
echo "`date` ${PGM} v${VER} @${HOSTNAME}" >> ${CSV}

echo "`date` ${PGM} v${VER} @${HOSTNAME}"| mailx -a ${CSV} -s "${PGM} v${VER}" "${MAILTO}"
echo "  Mailed to ${MAILTO}"|tee -a ${LOG}

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

