FelixSutarelli

Problem with script to restart application

Discussion created by FelixSutarelli on Sep 26, 2017
Latest reply on Sep 27, 2017 by Hiko_Davis

Hello everyone, I have a problem in my environment and I would like to know if someone has already experienced something similar: the situation is as follows:
- I have a script that I use to restart my applications, APM is monitoring the GC and when it reaches the threshold that I have set it executes the script to restart. This script generates a txt file where another script checks the status from time to time, if it is RESTART it restarts the application. My problem is that APM only generates the status of RESTART, it does not generate the status of NORMAL when the application is reinitialized.

 

#!/bin/sh
ALERT_STATUS=$2
AGENT_NAME=$3
AGENT_INSTANCIA=$AGENT_NAME

NOME_AGENTE=`echo $AGENT_NAME|awk -F"\|" '{print $(NF-2)}'`
NOME_AGENTE=`echo $NOME_AGENTE | sed -e "s/]\"//g"`

NOME_INSTANCIA=`echo $AGENT_INSTANCIA|awk -F"\|" '{print $(NF)}'`
NOME_INSTANCIA=`echo $NOME_INSTANCIA | sed -e "s/]\"//g"`

STATUS="INDEFINIDO"
if [ "$ALERT_STATUS" = "\"3\"" ]; then
        STATUS="RESTART"
        echo Nome_Agente: $NOME_AGENTE >/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo Nome_Instancia: $NOME_INSTANCIA >>/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo STATUS: $STATUS >>/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo `date` " - " Nome_Agente: $NOME_AGENTE - $STATUS >>/opt/appfiles/p_07667_apm/coletor1/mom/logs/restart.log
elif [ "$ALERT_STATUS" = "\"2\"" ]; then
        STATUS="ALERTA"
        echo Nome_Agente: $NOME_AGENTE >/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo Nome_Instancia: $NOME_INSTANCIA >>/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo STATUS: $STATUS >>/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo `date` " - " Nome_Agente: $NOME_AGENTE - $STATUS >>/opt/appfiles/p_07667_apm/coletor1/mom/logs/restart.log
else
        STATUS="NORMAL"
        echo Nome_Agente: $NOME_AGENTE >/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo Nome_Instancia: $NOME_INSTANCIA >>/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo STATUS: $STATUS >>/opt/websites/httpd/2.2/p_07667_apmstatus/$NOME_AGENTE-$NOME_INSTANCIA.txt
        echo `date` " - " Nome_Agente: $NOME_AGENTE - $STATUS >>/opt/appfiles/p_07667_apm/coletor1/mom/logs/restart.log
fi

 

In my logfile i just have this:

Qui Set 21 10:09:40 BRT 2017  -  Nome_Agente: xxxxxxx0434 - RESTART
Qui Set 21 10:09:40 BRT 2017  -  Nome_Agente: xxxxxxx0433 - RESTART
Qui Set 21 10:10:12 BRT 2017  -  Nome_Agente: xxxxxxx0432 - RESTART
Qui Set 21 10:16:10 BRT 2017  -  Nome_Agente: xxxxxxx0433 - ALERTA
Qui Set 21 10:16:25 BRT 2017  -  Nome_Agente: xxxxxxx0432 - ALERTA
Qui Set 21 10:18:25 BRT 2017  -  Nome_Agente: xxxxxxx0434 - ALERTA

 

Outcomes