首页 > 服务器 > Linux服务器 > 正文

Linux磁盘空间监控且报警的脚本

2024-09-05 22:52:37
字体:
来源:转载
供稿:网友

为了方便大家管理磁盘,我们给大家一个磁盘空间监控并报警的脚本

#!/bin/sh

  #make by itbit

  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:{GetProperty(Content)}" >> $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

 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表