监控磁盘空间并结合mutt发送报警邮件
#!/bin/sh
mkdir /tmp/process_monitor
cd /tmp/process_monitor
INIT()
{
IPADD=`ifconfig|grep 255.255|awk '{print $2}'|sed 's/addr://g'`;
Province_name="磁盘空间";
host_name=`hostname`;
NOWTIME=`date "+%Y年%m月%d日 %H:%M"`;
MAILTO="";
MAIL_SUB="$IPADD Disk Capacity Report $NOWTIME !";
tmpfile=disk_mon.tmp
}
mhead()
{
echo "" >$tmpfile;
echo "From :$Province_name $host_name $IPADD" >>$tmpfile
echo "State :Report" >>$tmpfile
echo "ReportBy:$0" >> $tmpfile
echo "DateTime:$NOWTIME" >> $tmpfile
echo "Info :$Province_name $host_name Disk Monitor" >> $tmpfile
echo "" >>$tmpfile;
}
smail()
{
/usr/local/mutt/bin/mutt -s "$IPADD Disk Capacity Report $NOWTIME !" $MAILTO < $tmpfile
}
INIT;
for x in `df | grep /dev | awk '{print $5}' | sed 's/%//g'`
do
if [ $x -gt 60 ]; then #配置告警阀值
mhead;
df -h >>$tmpfile;
smail;
exit 0;
fi
done
阅读(1681) | 评论(0) | 转发(0) |