• 邮件报警脚本


    #!/bin/bash
    #安装邮件
    rpm -q sendmail
     if [ $? -ne 0 ];then
             yum -y install sendmail
     fi
    rpm -q mutt
     if [ $? -ne 0 ];then
             yum -y install mutt
     fi
    systemctl restart sendmail
    #设置变量
    HOST=`hostname`
    SYS=`uname -a`
    DATE=`date "+%F %H:%M:%S"`
    CPU=`cat /proc/cpuinfo |grep processor | wc -l`
    ID=`vmstat | awk 'NR==3{print $15 }'`
    WA=`vmstat | awk 'NR==3{print $16 }'`
    LOAD=`w | awk 'NR==1{print $8}' |awk -F "," '{print $1}'`
    DISK=`df |awk '{if(NR==7){print int($5)}}'`
    FREE=`free -m | awk 'NR==2{print $4}'`
    CACHE=`free -m | awk 'NR==2{print $7}'`
    TCP=`netstat -atunlp`
    IF=`iftop -i ens33 -P -Nn -L 100 -s 1 -t`
    #cpu报警
     if [ $CPU -eq 4 ];then
      echo "wa=$WA and id=$ID cpu processor is ok"
     else
      echo "wa=$WA and id=$ID cpu processor have problem" |mutt -s "SYSTEM-memory" *********@163.com
     fi
     if [ $LOAD -gt 0.05 ];then
      echo "CPU-LOAD is beyond the rate" |mutt -s "CPU-LOAD" ***********@163.com
     else
      echo "CPU-LOAD is ok"
     fi
    #磁盘报警
     if [ $DISK -gt 80 ];then
      echo "SYSTEM-DISK is beyond the 80%" |mutt -s "SYSTEM-DISK" ************@163.com
     else
      echo "SYSTEM-DISK is ok"
     fi
    #内存报警
    memory=$(($FREE+$CACHE))
    echo $memory
     if [ $memory -lt 1000 ];then
      echo "SYSTEM-memory less than 1000M " |mutt -s "SYSTEM-memory" *************@163.com
            else
                    echo "SYSTEM-memory is ok"
            fi
  • 相关阅读:
    模糊查询的like '%$name$%'的sql注入避免
    在VS2010中使用Git(转)
    android WebView解析 调用html5
    git
    推荐!手把手教你使用Git
    羽毛拍十大品牌
    乒乓球拍板和皮子世界排名
    足球小记
    centos 网络启动 在/etc/sysconfig/network-scripts/ifcfg-eth1onboot=yes即可
    MyEclipseGen--------生成
  • 原文地址:https://www.cnblogs.com/cuiyupu/p/10405741.html
Copyright © 2020-2023  润新知