echo “script execution starts at `date`”
echo “COMFORT_SPACE=$COMFORT_SPACE”
echo “ARCH_DEST=$ARCH_DEST”
echo “ALERT_LOG=$ALERT_LOG”
ARCH_SPACE=`df -k $ARCH_DEST | tail -1 | awk ‘{print $5}’ | sed ‘s/%//g’`
echo “ARCH_SPACE=$ARCH_SPACE”
STDBY_LAST_RECOVERED_FILE=`grep “Media ” $ALERT_LOG |grep -v grep|grep “arch” | tail -1 | sed -e ‘s#^.*/##g’ `
echo “STDBY_LAST_RECOVERED_FILE=$STDBY_LAST_RECOVERED_FILE”
STDBY_LAST_RECOVERED_NUMBER=`grep “Media ” $ALERT_LOG |grep -v grep|grep “arch” | tail -1 | sed -e ‘s#^.*/##g’ |sed -e ‘s|[^0-9]||g’ `
echo “STDBY_LAST_RECOVERED_NUMBER=$STDBY_LAST_RECOVERED_NUMBER”
STDBY_SAFE_NUMBER=`expr $STDBY_LAST_RECOVERED_NUMBER – 5`
echo “STDBY_SAFE_NUMBER=${STDBY_SAFE_NUMBER}”
TOTAL_FILES_REMOVED=0
echo “The script execution started at `date`”
while [ ${ARCH_SPACE} -ge ${COMFORT_SPACE} ]
do
echo “At the Start-of-loop ARCH_SPACE=${ARCH_SPACE} and COMFORT_SPACE=${COMFORT_SPACE}”
FIRST_FILE=`ls -latr $ARCH_DEST/*.arc|head -1|awk ‘{print $9}’`
ONLY_FILE_NAME=`echo $FIRST_FILE | awk -F”/” ‘{print $NF}’`
SOURCE_FILE_NUMBER=`echo $ONLY_FILE_NAME | awk -F”/” ‘{print $NF}’ | sed -e ‘s|[^0-9]||g’`
echo “FIRST_FILE=${FIRST_FILE} ONLY_FILE_NAME=${ONLY_FILE_NAME} SOURCE_FILE_NUMBER=$SOURCE_FILE_NUMBER”
if [ ${SOURCE_FILE_NUMBER} -ge ${STDBY_SAFE_NUMBER} ]; then
echo “Issue: Cannot remove ${FIRST_FILE} from Standby `hostname`:${ARCH_DEST} as it is not applied to DR. Exiting…”
mailx -s “Blackberry: `hostname` : Archive File-System ${ARCH_DEST} space issue” $NOTIFY_LIST<
Issue: Cannot remove ${FIRST_FILE} from Standby `hostname`:${ARCH_DEST} as it is not applied to DR.
COMFORT_SPACE=${COMFORT_SPACE}% CURRENT_SPACE = ${ARCH_SPACE}%
DR: `hostname` Last Recovred File : ${STDBY_LAST_RECOVERED_FILE}
EOF
exit;
else
echo “removing the ${FIRST_FILE}…..”
rm ${FIRST_FILE}
echo “Removed ${FIRST_FILE} at `date`”
sleep 8
TOTAL_FILES_REMOVED=`expr $TOTAL_FILES_REMOVED + 1`
fi
sleep 8
ARCH_SPACE=`df -k $ARCH_DEST | tail -1 | awk ‘{print $5’} | sed ‘s/%//g’`
echo “At the End-of-loop ARCH_SPACE=${ARCH_SPACE} and COMFORT_SPACE=${COMFORT_SPACE}”
done
echo “Total files moved to $ARCH_DEST are ${TOTAL_FILES_REMOVED}”
echo “The script execution ended at `date`”