使用shell脚本进行服务器系统监控——文件系统监控(3)

释放双眼,带上耳机,听听看~!

#!/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=

1
1`

hostname

1
1`

 # 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      printfi 

给TA打赏
共{{data.count}}人
人已打赏
安全技术安全运维

Windows服务器如何发现被黑

2018-5-20 12:24:31

安全技术

bootstrap栅格系统自定义列

2021-12-21 16:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索