uCosminexus Application Server, Operation, Monitoring, and Linkage Guide

[Contents][Glossary][Index][Back][Next]

19.5.5 Creating a shell script

Create the following shell script files to monitor the processes of the Administration Agent and to start and stop the Administration Agent and logical servers:

In the (N number of) executing nodes
The shell script files that you must set in the executing nodes are described as follows. Note that you must use a common command in the N number of nodes.
  • Shell script file for monitoring the processes of the Administration Agent
  • Shell script file for starting the Administration Agent
  • Shell script file for stopping the Administration Agent and logical servers

In the standby node (One node for recovery)
The shell script file that you must set in the standby node is described as follows. Note that you use a common command for the N number of executing nodes and pass the differences with the arguments of the command.
  • Shell script file for executing the recovery process

Each script is described as follows:

Organization of this subsection
(1) Shell script file for monitoring the processes of the Administration Agent
(2) Shell script file for starting the Administration Agent
(3) Shell script file for stopping the Administration Agent and logical servers
(4) Shell script file for executing the recovery process

(1) Shell script file for monitoring the processes of the Administration Agent

An example of the shell script file for monitoring the processes of the Administration Agent (monitor.sh) is described as follows:

 
#!/bin/sh
 
LOGDIR=/home/manager/hamon/log
AA=/opt/Cosminexus/manager/bin/adminagent
 
logg()
{
    echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \
        >> ${LOGDIR}/adminagent.log 2>&1
}
 
logg "### $0: started. ###"
while true
do
    CHECK=`ps -ef | grep $AA | grep -v grep`
 
    if [ "$CHECK" = "" ]
    then
        logg "### $0: stop. ###"
        exit 0
    fi
    sleep 10
done
 

In this example, every 10 seconds, the shell script file monitors whether the processes of the Administration Agent exist.

(2) Shell script file for starting the Administration Agent

An example of the shell script file for starting the Administration Agent (start.sh) is described as follows:

 
#!/bin/sh
 
LOGDIR=/home/manager/hamon/log
MNGDIR=/opt/Cosminexus/manager
 
logg()
{
    echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \
        >> ${LOGDIR}/adminagent.log 2>&1
}
 
# start Administration Agent
logg "### $0: starting Administration Agent. ###"
$MNGDIR/bin/adminagentctl start
if [ $? -eq 0 ] ; then
  logg "### $0: Administration Agent start normally. ###"
else
  logg "### $0: Administration Agent cannot start. ###"
  exit 1
fi
 
exit 0
 

(3) Shell script file for stopping the Administration Agent and logical servers

An example of the shell script file for stopping the Administration Agent and logical servers (stop.sh) is described as follows:

 
#!/bin/sh
 
LOGDIR=/home/manager/hamon/log
MNGDIR=/opt/Cosminexus/manager
 
logg()
{
    echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \
        >> ${LOGDIR}/adminagent.log 2>&1
}
 
# stop logical server
logg "### $0: stop logical servers. ###"
$MNGDIR/bin/mngsvrutil -m mnghost:28080 -u admin -p admin \
                            -t 172.16.12.31 -k host -s stop server
 
# stop Administration Agent
logg "### $0: stopping Administration Agent. ###"
$MNGDIR/bin/adminagentctl stop
 
exit 0
 

The settings to be specified in the shell script file are described as follows. For details on the commands and files, see the manual Cosminexus Application Server Commands, or the manual Cosminexus Application Server Server Definitions.

(4) Shell script file for executing the recovery process

An example of the shell script file for executing the recovery process for each J2EE server (recover.sh) is described as follows:

 
#!/bin/sh
 
LOGDIR=/home/manager/hamon/log
PATH=/opt/Cosminexus/CC/server/bin:/bin:/usr/bin:/home/manager/hamon/bin
LD_LIBRARY_PATH=/opt/DABroker/lib:/opt/Cosminexus/jdk/lib:/opt/Cosminexus/TPB/lib:/opt/Cosminexus/PRF/lib:/opt/Cosminexus/CTM/lib:/bin:/opt/HiRDB/client/lib:/opt/oracle/app/oracle/product/10.1.0/client_1/lib:/opt/oracle/app/oracle/product/10.1.0/client_1/lib/libclntsh.so.10.1:/opt/oracle/app/oracle/product/10.1.0/client_1/lib/libclntsh.so
export LD_LIBRARY_PATH
 
LOCKFILE=/var/lock/kosmi_recover.lock
SLEEP_TIME=60
RETRIES=30
STATUS_PATH=$3/otsstatus
 
cjlockfile()
{
    counter=$2
    TMP_LOCK_FILE=`dirname $3`/$$.lock
    echo $$ > $TMP_LOCK_FILE
    if [ -f $3 ]
    then
        kill -0 `cat $3` 2>/dev/null || rm -f $3
    fi
 
    until ln $TMP_LOCK_FILE $3 2>/dev/null
    do
        counter=`expr $counter - 1`
        if [ $counter -le 0 ]
        then
            rm -f $TMP_LOCK_FILE
            return 1
        fi
        sleep $1
    done
 
    rm -f $TMP_LOCK_FILE
    return 0
}
 
logg()
{
    echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \
        >> ${LOGDIR}/adminagent.log 2>&1
}
 
if cjlockfile ${SLEEP_TIME} ${RETRIES} ${LOCKFILE}
then
    logg "### $0: started for $1 ###"
    cjstartrecover MyServer -p vbroker.se.iiop_tp.host=$2 \
                  -p ejbserver.distributedtx.ots.status.directory1=$STATUS_PATH \
                  -t 600
    logg "### $0: ended. $? ###"
fi
 
rm -f $LOCKFILE
 
exit 0
 

The settings to be specified in the shell script file are described as follows. For details on the commands and files, see the manual Cosminexus Application Server Commands, or the manual Cosminexus Application Server Server Definitions.

For the cjstartrecover command, see cjstartrecover (Recovering the J2EE server transactions) in the uCosminexus Application Server Command Reference Guide. For the ejbserver.distributedtx.ots.status.directory1 and vbroker.se.iiop_tp.host keys, see 2.4 usrconf.properties (User property file for J2EE servers) in the uCosminexus Application Server Definition Reference Guide.