17.7.6 Creating the shell script file
Create the following shell script files for monitoring the Management Server process, and for starting and stopping the Management Server:
-
Shell script file for monitoring the Management Server process
-
Shell script file for starting the Management Server
-
Shell script file for stopping the Management Server
You use the same shell script file in the Management Server of the active node and the Management Server of the spare node, and deploy the file in the same path.
- Organization of this subsection
(1) Shell script file for monitoring the Management Server process
An example of the shell script file for monitoring the Management Server process (manager_mngsvr_monitor.sh) is as follows:
#!/bin/sh LOGDIR=/home/manager/hamon/log MNGDIR=/opt/Cosminexus/manager logg () { echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \ >> ${LOGDIR}/mngsvr.log 2>&1 } logg "### $0: started. ###" while true do $MNGDIR/bin/mngsvrutil -m 192.168.255.111:28080 check mngsvr if [ $? -ne 0 ] then logg "### $0: stop. ###" exit 0 fi sleep 10 done
In this shell script file, you check the operational status of the Management Server with the check command of mngsvrutil. You specify the Alias IP address in the argument host name of the -m option of the mngsvrutil command.
(2) Shell script file for starting the Management Server
An example of the shell script file for starting the Management Server (manager_mngsvr_start.sh) is as follows:
#!/bin/sh LOGDIR=/home/manager/hamon/log MNGDIR=/opt/Cosminexus/manager RETRY_COUNT=20 RETRY_INTERVAL=10 logg () { echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \ >> ${LOGDIR}/mngsvr.log 2>&1 } # start Management Server logg "### $0: starting Management Server. ###" $MNGDIR/bin/mngsvrctl start & I=0 while [ $I -lt $RETRY_COUNT ] ; do $MNGDIR/bin/mngsvrutil -m 192.168.255.111:28080 check mngsvr if [ $? -eq 0 ] ; then break fi sleep $RETRY_INTERVAL I=`expr $I + 1` done exit 0
(3) Shell script file for stopping the Management Server
An example of the shell script file for stopping the Management Server (manager_mngsvr_stop.sh) is as follows:
#!/bin/sh LOGDIR=/home/manager/hamon/log MNGDIR=/opt/Cosminexus/manager logg () { echo `date '+[%Y/%m/%d %H:%M:%S]'`"[$$]: $1" \ >> ${LOGDIR}/mngsvr.log 2>&1 } # stop Management Server logg "### $0: stop Management Server. ###" $MNGDIR/bin/mngsvrctl stop exit 0