#!/usr/bin/ksh
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
df -k | tail +2 | egrep -v '/cdrom' /
| awk '{print $1, $4, $6}' > $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 "MB"
if (( $FSMB_FREE < $MIN_MB_FREE ))
then
(( FS_FREE_OUT = $FSMB_FREE / 1000 ))
echo "$FSDEVICE mounted on $FSMOUNT 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
本文介绍了一个用于监控文件系统的KornShell脚本。该脚本能够检查特定挂载点的可用空间,并在剩余空间低于设定阈值时生成警告报告。通过定制化的输出,管理员可以快速了解哪些文件系统接近满载状态。
9259

被折叠的 条评论
为什么被折叠?



