
#!/bin/ksh
#--------------------------------------------------------------------------#
#                                                                          #
# Name: check_snapshot_nxp.sh                                              #
#                                                                          #
# Description: Script collects data about snapshots in use for NXP         #
#              and sends information by mail.                              #
#                                                                          #
# Version: 1.0                                                             #
#                                                                          #
# References:                                                              #
#                                                                          #
# Documentation:                                                           #
#                                                                          #
# Parameters: none                                                         #
#                                                                          #
# Usage: check_snapshot_nxp.sh                                             #
#                                                                          #
# Global Description:                                                      #
#                                                                          #
# Author(s): Atos Origin                                                   #
#                                                                          #
# Change log:                                                              #
# aut   date          vers   comments                                      #
# RL    16-06-2009    1.0    Initial version Ronald ten Broeke             #
#                                                                          #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
# Initialize variabels                                                     #
#--------------------------------------------------------------------------#
CUSTOMERCODE=nxp
MAILTO="jeroen.terpstra@atosorigin.com john.swinkels@atosorigin.com"
MAILCC="corry.velema@atosorigin.com"
TMP=/tmp/check_snapshot_nxp.$$

#--------------------------------------------------------------------------#
# Collect data of vfilers and snapshots                                    #
#--------------------------------------------------------------------------#

for FILER in $(cat ${HOME}/etc/filers)
do
  for VFILER in `ssh ${FILER} vfiler status | grep ${CUSTOMERCODE} | awk '{ print $1 }'`
  do
    for VOLUME in `ssh ${FILER} vfiler run ${VFILER} vol status | grep online | grep -v ^vol0 | awk '{print $1}'`
    do
      ssh ${FILER} vfiler run ${VFILER} df -g ${VOLUME} >> $TMP
      ssh ${FILER} vfiler run ${VFILER} snap list ${VOLUME} | grep -v bo_nxp >> ${TMP}
    done
  done
done


#--------------------------------------------------------------------------#
# Send output in email.                                                    #
#--------------------------------------------------------------------------#

mailx -s "Snapshot backup info NXP" -c $MAILCC $MAILTO < ${TMP}

rm ${TMP}

