Link to home
Start Free TrialLog in
Avatar of ethanjohnsons
ethanjohnsons

asked on

df ksh and exclude a filesystem

I have df -k file system monitor script below.  What I need is to exclude /backup filesystem because it is always around 98 or 99%.   How do you put the line for excluding the /backup?

bla...

ALERT_ADMIN () { mail -s "${MAIL_SUBJ}"  $DIST_LIST  << EOF
Filesystem $fsname has reached $sz% of its capacity.
EOF
return
}

cd . > $WORKDIR/freespace.lst
exec 8< $WORKDIR/freespace.lst

df -k | grep -v -i filesystem | grep -v ":" | awk '{print $7,substr($4,1,2)}' |
grep -v "%" | grep -v proc > $WORKDIR/freespace.lst

if [ -f $WORKDIR/freespace.lst ]
then
 while read -u8 fsname sz ;
   do
   if [[ $sz -gt $WARNLEVEL ]]
     then
        ALERT_ADMIN
    fi
done
fi


thx much

      
Avatar of mglxxx
mglxxx

Like this?

df -k | tail +2 | sed 's,%,,' | awk ' $1 !~ /:|^\/proc|^\/backup/ { print $7,$4; }' > $WORKDIR/freespace.lst


Oops! Rather like this:
 df -k | tail +2 | sed 's,%,,' | awk ' $1 !~ /:|^\/proc/ && $7 !~ /^\/backup/ { print $7,$4; }'  
SOLUTION
Avatar of mglxxx
mglxxx

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial