您的位置:首页 > 其它

检查硬盘告警的脚本

2015-09-15 12:30 232 查看
改编自网络:

#!/bin/bash

mail=xxxx@xxx.com;

mailflag="true"

logfile=/root/check/checkdisk.log

#limit is 90

cat /dev/null > $logfile;

#count ,how many disks > 90%;

count=`df | grep -v mnt|grep -c -E \(9[1-9]\%\)\|\(100\%\)`;

if [ $count -gt 0 ];

then

echo "This is a alert for disk usage." >> $logfile

echo "host address:" >> $logfile

ifconfig |grep "inet addr" |grep -v "127.0.0.1" |awk '{print $2}'|awk -F ":" '{print $2}' >> $logfile

echo "disk info:" >> $logfile

df -h >> $logfile

if [ "$mailflag" == "true" ]; then mail -s "disk alert" $mail < $logfile;fi;

fi

注意:

邮件服务要正常,把sendmail装好。

发件地址如xxx.com要能ping到。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: