首頁(yè) > 服務(wù)器 > Linux服務(wù)器 > 正文

Linux磁盤(pán)空間監控且報警的腳本

2020-05-26 23:49:41
字體:
來(lái)源:轉載
供稿:網(wǎng)友

為了方便大家管理磁盤(pán),我們給大家一個(gè)磁盤(pán)空間監控并報警的腳本

#!/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

 

發(fā)表評論 共有條評論
用戶(hù)名: 密碼:
驗證碼: 匿名發(fā)表