I am writing a script to check the no of logs a directory can hold and % of disk space available. If directory can hold only 50 logs more or disk % available is only 80% then Alert the admin. Though the below code works, I was looking at a better script which might elimnate calling df -k multiple times to get different fields for comparison. This would make a concise code.
ARCAREA=/archives
DISKSPACE=`df -k $ARCAREA |grep -v "Available" |awk '{print $4}'`
TOTALLOG=`expr "$DISKSPACE" \* 1024 / "$LOGSIZE"`
PERCSPACE=`df -k $ARCAREA | grep -v Capacity | sed "s/%//g" |awk '{print $5}'`
echo "The Primary Archive Destination : $ARCAREA$"
echo "Max Size Of Each Archive Logs : $LOGSIZE$ bytes"
echo "Number Of Logs That Can Fit In : $TOTALLOG}"
echo "Available Perc Of Disk Space : $PERCSPACE"
if [ $PERCSPACE -gt 80 -o $TOTALLOG -lt 50 ] ; then
echo " Problem Available"
else
echo " NoProblem Available"
fi
ARCAREA=/archives
DISKSPACE=`df -k $ARCAREA |grep -v "Available" |awk '{print $4}'`
TOTALLOG=`expr "$DISKSPACE" \* 1024 / "$LOGSIZE"`
PERCSPACE=`df -k $ARCAREA | grep -v Capacity | sed "s/%//g" |awk '{print $5}'`
echo "The Primary Archive Destination : $ARCAREA$"
echo "Max Size Of Each Archive Logs : $LOGSIZE$ bytes"
echo "Number Of Logs That Can Fit In : $TOTALLOG}"
echo "Available Perc Of Disk Space : $PERCSPACE"
if [ $PERCSPACE -gt 80 -o $TOTALLOG -lt 50 ] ; then
echo " Problem Available"
else
echo " NoProblem Available"
fi