#!/bin/sh
CORE_FILES_DIR=/core_files
FFDC_FILES_DIR=/core_files/ffdc_data
MNT_DIR=/mnt


# we don't care if the total core files amounts to less that 5 K bytes
# LOWER_LIMIT will set this limit under with we don't care to report
LOWER_LIMIT=5

# First, if there is no CORE_FIELS_DIR then we are done :-)
if [ ! -d ${CORE_FILES_DIR} ]
then
	exit
fi
# let us figure out how much core files are occupying...
ROOTkbytes=`/usr/bin/du -sk ${CORE_FILES_DIR} | cut -f1`
MNTkbytes=`/usr/bin/du -sk ${MNT_DIR}/${CORE_FILES_DIR} | cut -f1`
Ffdckbytes=`/usr/bin/du -sk ${FFDC_FILES_DIR} | cut -f1`
MNTFfdckbytes=`/usr/bin/du -sk ${MNT_DIR}/${FFDC_FILES_DIR} | cut -f1`
corekbytes=`expr ${ROOTkbytes} + ${MNTkbytes} - ${Ffdckbytes} - ${MNTFfdckbytes}`
ffdckbytes=`expr ${Ffdckbytes} + ${MNTFfdckbytes}`

ROOTnumberOfCoreFiles=`/usr/bin/find /${CORE_FILES_DIR}/ \( -name "*core*" \) -type f -print | \
wc -l | sed -e's/[ 	]//g'`
MNTnumberOfCoreFiles=`/usr/bin/find ${MNT_DIR}/${CORE_FILES_DIR}/ \( -name "*core*" \) -type f -print | \
wc -l | sed -e's/[ 	]//g'`
numberOfCoreFiles=`expr ${ROOTnumberOfCoreFiles} + ${MNTnumberOfCoreFiles}`

ROOTnumberOfFfdcFiles=`/usr/bin/find /${FFDC_FILES_DIR}/ \( -name "*ffdc*" \) -type f -print | \
wc -l | sed -e's/[ 	]//g'`
MNTnumberOfFfdcFiles=`/usr/bin/find ${MNT_DIR}/${FFDC_FILES_DIR}/ \( -name "*ffdc*" \) -type f -print | \
wc -l | sed -e's/[ 	]//g'`
numberOfFfdcFiles=`expr ${ROOTnumberOfFfdcFiles} + ${MNTnumberOfFfdcFiles}`

if [ ${numberOfCoreFiles} -ge 1 ]
then
	printf "
*** CORE FILES WARNING (%-20s) ***
%s KBytes in %s file(s)
use \"supportsave\" command on Active CP to upload 

" "`/bin/date +'%D - %T'`"  ${corekbytes} ${numberOfCoreFiles} > /dev/console
fi

if [ ${numberOfFfdcFiles} -ge 1 ]
then
	printf "
*** FFDC FILES WARNING (%-20s) ***
%s KBytes in %s file(s)
use \"supportSave\" command on Active CP to upload

" "`/bin/date +'%D - %T'`"  ${ffdckbytes} ${numberOfFfdcFiles} > /dev/console

fi
