zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    UnityShader
    Unity
    Tools
    linux下解压命令
    进程 同步、互斥
    I/O模型
    jclass jobject
    javah javap
    IDA 结构体
    Windows CSRSS API List (NT/2000/XP/2003/Vista/2008/7/2012/8)
  • 原文地址:https://www.cnblogs.com/lubing666666/p/4366104.html
Copyright © 2011-2022 走看看