#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export LANG=en_US.UTF-8
[ $(id -u) -gt 0 ] && echo "please use root run the script! " && exit 1
ProcNam=cljj_fof
PPATH=/cljj/apps/50cljj_fof
URLS=http://127.0.0.1:9015/webfof_login/login
MAIL=`which mail`
IP=`ip addr| grep eth0 |grep inet |egrep -v "inet6|127.0.0.1" |awk '{print $2}' |awk -F "/" '{print $1}'`
LOG=/tmp/process_monitor.log
TIME=$(date +%Y-%m-%d-%H-%M-%S)
curl_ip() {
CURL=$(curl -o /dev/null -s --connect-timeout 5 -w '%{http_code}' $1|egrep "200|302"|wc -l)
return $CURL
}
ProcNum=`ps -ef|grep $ProcNam | grep -v grep |wc -l`
curl_ip $URLS &> /dev/null
if [ $CURL -eq 0 -o $ProcNum -eq 0 ]; then
$PPATH/startx.sh &> /dev/null
if [ $? -eq 0 ];then
echo "-------$TIME-------" >> $LOG
echo "starting $ProcNam..." >> $LOG
echo "$ProcNam is restarted!!" >> $LOG
sleep 10
curl_ip $URLS &> /dev/null
if [ $CURL -ne 1 ];then
echo "$ProcNam state is failure on $TIME,Please check FOF on $IP!!" | $MAIL -s " FOF state Warning" liujian@erichfund.com
else
echo "$ProcNam status is ok" >> $LOG
fi
fi
fi