Listing 1: dfck
#!/bin/sh
#
# check amount of disk space left on devices
#
MAXPERCENT=90 # % full trigger
#
HOST=`hostname`
TMP=/tmp/dfck.$$
rm -rf $TMP
if [ -f /vmunix ]; then # get Berkeley df(1)
DFCOMMAND=/bin/df # if SunOS
else
DFCOMMAND=/usr/ucb/df # if SVR4
fi
$DFCOMMAND | grep "^/" | tr "%" " " |\
awk '{ if ( $5 > '$MAXPERCENT' ) print $6 " (" $1 ") " $5"%"}' \
>$TMP
n=`wc -l $TMP | awk '{print $1}'`
if [ $n -gt 0 ]; then
echo " "
echo "The following filesystems on $HOST are more than ${MAXPERCENT}% full:"
echo " "
sed 's/^/ /' $TMP
echo " "
fi
rm -f $TMP
|