FileSystem Check

From Notes

Jump to: navigation, search
#!/bin/bash

#
# Purpose:      The purpose of this script is to check a systems filesystem
#               and verify that it is not full.
#
# Author:       Josh Miller
# Date:         10/13/2006
#

NOTIFY="email@address"
HOSTNAME=$(hostname)

DF="/bin/df"
FS='/www /tmp'

EGREP="/bin/egrep"
AWK="/bin/awk"
SED="/bin/sed"

WARN="90"
CRIT="95"

for i in $FS
do
  RSLT=$(${DF} ${i} | $EGREP $i | $AWK '{print $5}' | ${SED} 's/\%//g')
  if [[ ${RSLT} -lt ${CRIT} && ${RSLT} -gt ${WARN} ]]
  then
    echo WARNING:  ${i} is ${RSLT}% full
  fi
  if [[ ${RSLT} -gt ${CRIT} ]]
  then
    echo "CRITICAL:  ${i} is ${RSLT}% full" | mail -s "FileSystem full warning on ${HOSTNAME}" ${NOTIFY}
  fi
done
Personal tools