一个监控磁盘空间大小并自动报警的脚本

来源:赛迪网 作者:sixth
  
#!/bin/sh

#make by codfei

init()
{
IPADD=`ifconfig|grep 172.18|awk '{print $2}'|sed 's/addr://g'`;
NOWTIME=`date +%F-%H:%M`;
MAILTO="";
MAIL_SUB=" !**Report - Disk Capacity Report $NOWTIME **!";
tmpfile=/tmp/iamatmpfile.tmp
}

mhead()
{
        echo "" >$tmpfile;
        echo "From :$IPADD" >>$tmpfile
        echo "State :Report" >>$tmpfile
        echo "ReportBy:$0" >> $tmpfile
        echo "DateTime:$NOWTIME" >> $tmpfile
        echo "Info :codfei" >> $tmpfile
        echo "" >>$tmpfile;
}

smail()
{
mail -s "$MAIL_SUB" $MAILTO < $tmpfile

}
init;

for x in `df | grep /dev | awk '{print $5}' | sed 's/%//g'`
do

  if [ $x -gt 89 ]; then
  mhead;
  df -h >>$tmpfile;
  smail;
  exit 0;
  fi

done

 

(责任编辑:A6)


时间:2007-10-18 09:59 来源:赛迪网 作者:sixth 原文链接

好文,顶一下
(0)
0%
文章真差,踩一下
(0)
0%
------分隔线----------------------------


把开源带在你的身边-精美linux小纪念品
无觅相关文章插件,快速提升流量