#!/bin/sh

FILERS="fscl1-1 fscl2-1 fscl3-1"

for FILER in ${FILERS}; do
  case ${FILER} in
    "fscl1-1")
      VOLUMES="home student"
      VSERVER="fs1-3"
    ;;
    "fscl2-1")
      VOLUMES="cifs home student"
      VSERVER="fs2-7"
    ;;
    "fscl3-1")
      VOLUMES="home student"
      VSERVER="fs3-3"
    ;;
  esac
  for VOLUME in ${VOLUMES}; do
    ssh quota-report@${FILER}mg.sto.slu.se "set -showseparator \",\" -units raw -showallfields false; quota report -vserver ${VSERVER} -volume ${VOLUME} -fields quota-target,disk-used,files-used" | tail -n +4 | awk -F ',' '/AD\\/{print$4","$5","$6}' | sort | uniq > /tmp/${VSERVER}_${VOLUME}_quota_report.txt 
  done
done
REPORT_FILES=$(ls -1 /tmp/*_quota_report.txt)
for REPORT_FILE in ${REPORT_FILES}; do
  ATTACHMENTS="${ATTACHMENTS} -a ${REPORT_FILE}"
done
ATTACHMENTS=$(echo ${ATTACHMENTS} | sed 's/^ //')
echo "NetApp Quota Report $(date +%Y%m%d)" | mutt ${ATTACHMENTS} -s "NetApp Quota Report $(date +%Y%m%d)" -- bo.sarling@slu.se
rm -f /tmp/*_quota_report.txt
