#!/usr/bin/ksh
WORKFILE="/tmp/df.work" # Holds filesystem data>$WORKFILE # Initialize to emptyOUTFILE="/tmp/df.outfile" # Output display file>$OUTFILE # Initialize to emptyTHISHOST=`hostname` # Hostname of this machineMIN_MB_FREE="50MB" # Min. MB of Free FS Space
df -k | tail +2 | egrep -v '/cdrom' / | awk '{print $1, $4, $6}' > $WORKFILE
# Format Variables(( MIN_MB_FREE = $(echo $MIN_MB_FREE | sed s/MB//g) * 1024 ))
# Loop through each line of the file and compare column 2
while read FSDEVICE FSMB_FREE FSMOUNTdo FSMB_FREE=$(echo $FSMB_FREE | sed s/MB//g) # Remove the "MB" if (( $FSMB_FREE < $MIN_MB_FREE )) then (( FS_FREE_OUT = $FSMB_FREE / 1000 )) echo "$FSDEVICE mounted on $FSMOUNT has ${FS_FREE_OUT}MB Free" / >> $OUTFILE fidone < $WORKFILE
if [[ -s $OUTFILE ]]then echo "/nFull Filesystem(s) on $THISHOST/n" cat $OUTFILE printfi