监控进程脚本

2017-02-25  本文已影响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

上一篇下一篇

猜你喜欢

热点阅读