美文网首页
监控进程脚本

监控进程脚本

作者: 乔伊斯 | 来源:发表于2017-02-25 14:42 被阅读0次

    #!/bin/bash

    node=`ip addr|grep -v 127.0.0.|grep -w inet|awk -F'/' '{print $1}'|awk '{printf $2","}'`

    TitleA="LF/Riak-cs node ${node} Statu  Not OK "

    TitleB="LF/Riak-cs node ${node} Statu  OK "

    To="songyingjun1@qq.com"

    ccAddress="songyingjun1@qq.com"

    process_check=`/bin/netstat -tunpl|grep beam.smp|grep 8098|wc -l`

    rm -f /usr/tmp/alert_mail_record

    while true

    do

    if [ "$process_check" != 1 ];then

    sudo /usr/sbin/riak-admin cluster status|sudo /usr/bin/mail -s "$TitleA" -c "$ccAddress" $To

        if [ $? -eq 0 ];then

        echo "`date` SendEmail Successful..." >> /usr/tmp/alert_mail_record

        fi

    sudo /usr/sbin/riak start

        if [ $? -eq 0 ];then

        sudo /usr/sbin/riak-admin cluster status|sudo /usr/bin/mail -s "$TitleB" -c "$ccAddress" $To

        else

        echo "`date` Start Riak unSuccessful..." >> /usr/tmp/alert_mail_record

        fi

    fi

    sleep 30

    done

    相关文章

      网友评论

          本文标题:监控进程脚本

          本文链接:https://www.haomeiwen.com/subject/sotnwttx.html