
#!/bin/ksh
# Script to check if all volumes are exported
# 20071115 RtB


# Check exported volumes and export file
LOGF=/users/nldsm01/scripts/data/output/vol_exports.log

VOLlist=`ssh hwnaf01 vol status | grep online | grep ec_vault | awk '{print $1}' | sort`

# Check volumes for fs_size_fixed and fractional_reserve values
for VOL in $VOLlist
do
  FSF=`ssh hwnaf01 vol options $VOL | grep fs_size_fixed=on`
  FRV=`ssh hwnaf01 vol options $VOL | grep fractional_reserve | grep -v fractional_reserve=0`

  if test "${FSF}"
  then
     echo "/vol/$VOL has fs_size_fixed set to ON" >> $LOGF
  else
     if test "${FRV}"
     then
        echo "/vol/$VOL has fractional_reserve not set to zero" >> $LOGF
     fi
  fi
done


# Filerchecks

for filer in hwnaf01 nlnaf02
do
VOLlist=`ssh $filer vol status | grep offline | grep vault | awk '{print $1}' | sort`

# Check for offline volumes
if test "${VOLlist}"
then
  for VOL in $VOLlist
  do
    echo "/vol/$VOL is offline" >> $LOGF
  done
fi

done

# Check filers for volumes that are not exported / are not in the exportfile

VOLlist=`ssh $filer vol status | grep online | grep vault | awk '{print $1}' | sort`

for VOL in `echo $VOLlist`
do

FTEST=`grep $VOL /filers/$filer/vol0/etc/exports`
ETEST=`ssh $filer exportfs | grep $VOL`

if test -z "$FTEST"
then
echo "/vol/$VOL is not mentioned in the exports file" >> $LOGF
fi

if test -z "$ETEST"
then
echo "/vol/$VOL is not exported" >> $LOGF
fi

done

# Check rw exported volumes
EXCLUDES="vault099|vault164|restore|vol0"

RW_LIST=`ssh hwnaf01 exportfs | grep rw | /usr/xpg4/bin/grep -v -E "${EXCLUDES}"`

if test -n "${RW_LIST}"
then
echo "Exports with rw rights: $RW_LIST" >> $LOGF
fi    

if test -f $LOGF
then
   cat $LOGF | mailx -s ":hwnaf01: Healthcheck for volumes" gmnl-msscentral@atosorigin.com
   rm $LOGF
fi

