#!/usr/bin/ksh # # SCRIPT: fs_mon.ksh # AUTHOR: Randy Michael # DATE: 08-22-2007 # REV: 1.5.P # PURPOSE: This script is used to monitor for full filesystems, # which is defined as "exceeding" the FSMAX value. # A message is displayed for all "full" filesystems. # # REV LIST: # Randy Michael - 08-27-2007 # Changed the code to use MB of free space instead of # the %Used method. # # set -n # Uncomment to check syntax without any execution # set -x # Uncomment to debug this script # ##### DEFINE FILES AND VARIABLES HERE #### WORKFILE="/tmp/df.work" # Holds filesystem data >$WORKFILE # Initialize to empty OUTFILE="/tmp/df.outfile" # Output display file >$OUTFILE # Initialize to empty THISHOST=`hostname` # Hostname of this machine MIN_MB_FREE="50MB" # Min. MB of Free FS Space ######## START OF MAIN ############# # Get the data of interest by stripping out /dev/cd#, # /proc rows and keeping columns 1, 4 and 7 df -k | tail +2 | egrep -v '/dev/cd[0-9] | /proc' \ | awk '{print $1, $3, $7}' > $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 FSMOUNT do FSMB_FREE=$(echo $FSMB_FREE | sed s/MB//g) # Remove the % sign if (( $FSMB_FREE < $MIN_MB_FREE )) then (( FS_FREE_OUT = $FSMB_FREE / 1000 )) echo "$FSDEVICE mounted on $FSMOUNT only has ${FS_FREE_OUT}MB Free" \ >> $OUTFILE fi done < $WORKFILE if [[ -s $OUTFILE ]] then echo "\nFull Filesystem(s) on $THISHOST\n" cat $OUTFILE print fi