Chinaunix
标题:
监控磁盘空间并发送报警邮件的shell脚本
[打印本页]
作者:
forward51
时间:
2009-10-11 19:34
标题:
监控磁盘空间并发送报警邮件的shell脚本
监控磁盘空间并结合mutt发送报警邮件
mutt+msmtp的配置见
http://blog.chinaunix.net/u2/89418/showart_2065694.html
#!/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="
lantu.service@gmail.com
";
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
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
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u2/89418/showart_2067820.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2