• checkAPP


    [root@BMS001 opt]# cat /opt/checkApp.sh
    #!/bin/bash

    . /etc/profile

    LOG_FILE="/opt/app_monitor.log"
    RET=0


    APP_NAME="/opt/bms_pc_7061"
    PORT_NAME="7061"

    echo '######################################### $APP_NAME  MONITOR ###################################' >> ${LOG_FILE}
    NUM1=`ps -ef| grep -w ${APP_NAME} |grep -v grep| wc -l`

    /usr/bin/nc -v -z -w2 192.168.50.230 7061
    if  test $? -eq 0 && [ "$NUM1" -eq "1" ] ;then
      echo "`date` $APP_NAME  is live" >> ${LOG_FILE}
    else
      RET=1
      echo "`date` $APP_NAME  is death"
      /bin/su - unify_bms -c "leo stop /opt/bms_pc_7061"
     
      sleep 2
      ps -ef | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
      sleep 3
       /bin/su - unify_bms -c "leo start /opt/bms_pc_7061"
      echo "`date` $APP_NAME restart  finished." >> ${LOG_FILE}
    fi

    echo '######################################### $APP_NAME FINISHED ######################################' >> ${LOG_FILE}
    APP_NAME="/opt/bms_pc_7062"
    PORT_NAME="7062"

    echo '######################################### $APP_NAME  MONITOR ##############
    ######################' >> ${LOG_FILE}
    NUM1=`ps -ef| grep -w ${APP_NAME} |grep -v grep| wc -l`

    /usr/bin/nc -v -z -w2 192.168.50.230 7062
    if  test $? -eq 0 && [ "$NUM1" -eq "1" ] ;then
      echo "`date` $APP_NAME  is live" >> ${LOG_FILE}
    else
      RET=1
      echo "`date` $APP_NAME  is death"
      /bin/su - unify_bms -c "leo stop /opt/bms_pc_7062"

      sleep 2
      ps -ef | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
      sleep 3
       /bin/su - unify_bms -c "leo start /opt/bms_pc_7062"
      echo "`date` $APP_NAME restart  finished." >> ${LOG_FILE}
    fi

    echo '######################################### $APP_NAME FINISHED ##############
    #########################' >> ${LOG_FILE}
    APP_NAME="/opt/bms_pc_adapter_7021"
    PORT_NAME="7021"

    echo '######################################### $APP_NAME  MONITOR ##############
    #
    ######################' >> ${LOG_FILE}
    NUM1=`ps -ef| grep -w ${APP_NAME} |grep -v grep| wc -l`

    /usr/bin/nc -v -z -w2 192.168.50.230 7021
    if  test $? -eq 0 && [ "$NUM1" -eq "1" ] ;then
      echo "`date` $APP_NAME  is live" >> ${LOG_FILE}
    else
      RET=1
      echo "`date` $APP_NAME  is death"
      /bin/su - unify_bms -c "leo stop /opt/bms_pc_adapter_7021"

      sleep 2
      ps -ef | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}' | xargs kill -9  >/dev/null 2>&1
      sleep 3
       /bin/su - unify_bms -c "leo start /opt/bms_pc_adapter_7021"
      echo "`date` $APP_NAME restart  finished." >> ${LOG_FILE}
    fi

    echo '######################################### $APP_NAME FINISHED ##############
    #
    #########################' >> ${LOG_FILE}
    APP_NAME="/opt/bms_pc_adapter_7022"
    PORT_NAME="7022"

    echo '######################################### $APP_NAME  MONITOR ##############
    #
    #
    ######################' >> ${LOG_FILE}
    NUM1=`ps -ef| grep -w ${APP_NAME} |grep -v grep| wc -l`

    /usr/bin/nc -v -z -w2 192.168.50.230 7022
    if  test $? -eq 0 && [ "$NUM1" -eq "1" ] ;then
      echo "`date` $APP_NAME  is live" >> ${LOG_FILE}
    else
      RET=1
      echo "`date` $APP_NAME  is death"
      /bin/su - unify_bms -c "leo stop /opt/bms_pc_adapter_7022"

      sleep 2
      ps -ef | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
      sleep 3
       /bin/su - unify_bms -c "leo start /opt/bms_pc_adapter_7022"
      echo "`date` $APP_NAME restart  finished." >> ${LOG_FILE}
    fi

    echo '######################################### $APP_NAME FINISHED ##############
    #
    #
    #########################' >> ${LOG_FILE}
    APP_NAME="/opt/bms3a_7001"
    PORT_NAME="7001"

    echo '######################################### $APP_NAME  MONITOR ##############
    #
    ######################' >> ${LOG_FILE}
    NUM1=`ps -ef| grep -w ${APP_NAME} |grep -v grep| wc -l`

    /usr/bin/nc -v -z -w2 192.168.50.230 7001
    if  test $? -eq 0 && [ "$NUM1" -eq "1" ] ;then
      echo "`date` $APP_NAME  is live" >> ${LOG_FILE}
    else
      RET=1
      echo "`date` $APP_NAME  is death"
      /bin/su - unify_bms -c "leo stop /opt/bms3a_7001"

      sleep 2
      ps -ef | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}' | xargs kill -9  >/dev/null 2>&1
      sleep 3
       /bin/su - unify_bms -c "leo start /opt/bms3a_7001"
      echo "`date` $APP_NAME restart  finished." >> ${LOG_FILE}
    fi

    echo '######################################### $APP_NAME FINISHED ##############
    #
    #########################' >> ${LOG_FILE}
    APP_NAME="/opt/bms3a_7002"
    PORT_NAME="7002"

    echo '######################################### $APP_NAME  MONITOR ##############
    #
    #
    ######################' >> ${LOG_FILE}
    NUM1=`ps -ef| grep -w ${APP_NAME} |grep -v grep| wc -l`

    /usr/bin/nc -v -z -w2 192.168.50.230 7002
    if  test $? -eq 0 && [ "$NUM1" -eq "1" ] ;then
      echo "`date` $APP_NAME  is live" >> ${LOG_FILE}
    else
      RET=1
      echo "`date` $APP_NAME  is death"
      /bin/su - unify_bms -c "leo stop /opt/bms3a_7002"

      sleep 2
      ps -ef | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
      sleep 3
       /bin/su - unify_bms -c "leo start /opt/bms3a_7002"
      echo "`date` $APP_NAME restart  finished." >> ${LOG_FILE}
    fi

    echo '######################################### $APP_NAME FINISHED ##############
    #
    #
    #########################' >> ${LOG_FILE}
    exit $RET

  • 相关阅读:
    ubuntu14.04 Cannot find OpenSSL's <evp.h>
    git 常用命令
    Python3常用模块的安装
    Centos7 安装配置优化mysql(mariadb分支)
    Centos7 编译安装python3
    Centos6.5搭建git远程仓库
    年轻
    springboot 报错Field XXX required a bean of type XXX that could not be found.
    springboot 启动报错[classpath:/application.yml] but snakeyaml was not found on the classpath
    idea 使用点击maven clean/install或maven其他命令失败,显示:乱码+archetypeCatalog=internal
  • 原文地址:https://www.cnblogs.com/lubing666666/p/4366104.html
Copyright © 2020-2023  润新知