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
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
Oops! Rather like this:
df -k | tail +2 | sed 's,%,,' | awk ' $1 !~ /:|^\/proc/ && $7 !~ /^\/backup/ { print $7,$4; }'
df -k | tail +2 | sed 's,%,,' | awk ' $1 !~ /:|^\/proc/ && $7 !~ /^\/backup/ { print $7,$4; }'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
df -k | tail +2 | sed 's,%,,' | awk ' $1 !~ /:|^\/proc|^\/backup/ { print $7,$4; }' > $WORKDIR/freespace.lst