
#!/bin/sh
# File	: get_dfm_thresholds.sh
# By	: Maarten de Boer, 100830
# Subject	: Get the list of tresholds & put into .CSV

PGM="`basename $0|cut -d\. -f1`"
TMP="/tmp/${PGM}.$$"
MAILTO="maarten.deboer@atosorigin.com"
HOSTNAME="`hostname`"
DATE="`date +%Y-%m-%d`"
CSV="DFM-thresholds_${HOSTNAME}_${DATE}.csv"

# Aggr's
dfm aggr get -q |while read LINE
  do
# if line <> "" then add ;
  if [ "$LINE" != "" ]; then
    echo "$LINE;"  >> ${TMP}
  else
    echo "" >> ${TMP}
  fi
done

#Volumes
dfm volume get -q |while read LINE
  do
# if line <> "" then add ;
  if [ "$LINE" != "" ]; then
    echo "$LINE;"  >> ${TMP}
  else
    echo "" >> ${TMP}
  fi
done

# Strip NEWlines (make one line per entry)
cat $TMP | nawk 'BEGIN {RS=""}
{
  t=0
  while (++t<=NF) {printf "%s ", $t}
  printf "\n"
}'file | uuencode ${CSV} | mailx -s "${PGM}" ${MAILTO}

echo "Mailed to ${MAILTO} "

rm ${TMP}
exit

