Hitachi

uCosminexus Application Server Operation, Monitoring, and Linkage Guide


9.4.6 Settings of Management Action Execution Commands

You can code the commands to be executed as Management actions in the command files (batch files or shell script files). Create command files as required. Note that for batch servers, you cannot use request scheduling by CTM, and therefore, CTM- related description is not applicable.

The following are the environment variables that can be used in the command files and samples of command files:

Organization of this subsection

(1) Environment variables that can be used in command files

The following table lists the environment variables that you can use in the command files:

Table 9‒4: Environment variables that can be used in the command files of the management action execution commands

Environment variable

Description

COSMI_MNG_MACT_LSNAME

Logical server name from where the Management event is issued.

COSMI_MNG_MACT_HOST

Host name of a logical server from where the Management event is issued.

COSMI_MNG_MACT_MSG_ID

Message ID issued by the Management event.

COSMI_MNG_MACT_MSG_TEXT

Message text issued by the Management event.

COSMI_MNG_MACT_CTM

Logical CTM name specified for the logical server from where the management event is issued.

COSMI_MNG_MACT_WEBSYSTEM

Web system name to which the logical server, from where the Management event is issued, belongs.

COSMI_MNG_MACT_UNIT

Service unit name to which the logical server, from where the Management event is issued, belongs.

COSMI_MNG_MACT_TIER

Physical tier type to which the logical server, from where the Management event is issued, belongs.

COSMI_MNG_MACT_OPTN

An option string notified by the Management event. The embedded characters of the message are used as option string. N is an integer from 0 and above, and the environment variable expressing the first option string is COSMI_MNG_MACT_OPT0.

For details on the set strings, see the information displayed in the variable values of the message text of messages that issue Management events.

COSMI_MNG_MACT_MNGSVR_PORT

HTTP port number of a Management Server.

COSMI_MNG_MACT_RNAME

Actual server name of the logical server from where the Management event is issued.

COSMI_MNG_MACT_NS_HOSTPORT

Host name and port number of the naming service used by the logical server from where the Management event is issued. For example: HostA:900, when the host name is HostA and the port number is 900.

(2) Samples of command files

Reference the provided samples of command files and create a command file. The samples are stored in the following location:

For using a sample, change the arguments of the mngsvrutil command (such as -m, -u, and -p options), and the storage destination of a log file in conformity with the environment.

(a) Sample to restart the server that issues Management events

File name of a sample
  • In Windows: mActionSample_restartServer.bat

  • In UNIX: mActionSample_restartServer.sh

Operating the sample

Restart the logical server from where the Management event is issued.

You can use this sample to issue Management events with the resource depletion monitoring function.

  1. The resource depletion monitoring functionality monitors the memory usage of a Java VM, and outputs a message if Full GC is likely to occur when the threshold value that is set is exceeded.

  2. The Management event issuing function executes a Management action after issuing a Management event in correspondence with the output message, and restarts the J2EE server from where the Management event is issued.

By terminating the J2EE server from where the Management event is issued, you can block the J2EE application. Furthermore, if the J2EE server uses CTM for the load balancing of requests, you can terminate the J2EE server for distributing new requests to other J2EE servers.

The sample to restart the server from where the Management event is issued is described below:

  • In Windows

       (Omitted)
        ...
    rem Management action sample for restart server.
     
    setlocal
     
    set LSNAME=%COSMI_MNG_MACT_LSNAME%
    set MSGID=%COSMI_MNG_MACT_MSG_ID%
     
    set CJCLDELLOG=%COSMINEXUS_HOME%\CC\client\bin\cjcldellog.bat
    set LOG_ROOT_DIR=%SystemDrive%\<MyLogDir>
    if not exist "%LOG_ROOT_DIR%" mkdir "%LOG_ROOT_DIR%"
    call "%CJCLDELLOG%" -t 30d -f "%LOG_ROOT_DIR%"
    set LOG_DIR=%LOG_ROOT_DIR%\%date:/=%
    if not exist "%LOG_DIR%" mkdir "%LOG_DIR%"
    set LOG=%LOG_DIR%\%time::=%_%LSNAME%_%MSGID%.txt
     
    echo %0 > "%LOG%"
     
    set MNGSVR=localhost:%COSMI_MNG_MACT_MNGSVR_PORT%
    set UID=<User-id>
    set PWD=<Password>
     
    echo mngsvrutil.exe -m %MNGSVR% -u %UID% -p %PWD% -t %LSNAME% -s stop server >> "%LOG%" 2>&1
    mngsvrutil.exe -m %MNGSVR% -u %UID% -p %PWD% -t %LSNAME% -s stop server >> "%LOG%" 2>&1
    set RET=%ERRORLEVEL%
    echo %RET% >> "%LOG%"
     
    if not %RET% == 0 goto END
    echo mngsvrutil.exe -m %MNGSVR% -u %UID% -p %PWD% -t %LSNAME% -s start server >> "%LOG%" 2>&1
    mngsvrutil.exe -m %MNGSVR% -u %UID% -p %PWD% -t %LSNAME% -s start server >> "%LOG%" 2>&1
    set RET=%ERRORLEVEL%
    echo %RET% >> "%LOG%"
     
    :END
    exit %RET%
  • In UNIX

       (Omitted)
        ...
    # Management action sample for restart server.
     
    LSNAME=${COSMI_MNG_MACT_LSNAME}
    MSGID=${COSMI_MNG_MACT_MSG_ID}
     
    LOG_ROOT_DIR=/tmp/<MyLogDir>
    if [ ! -d ${LOG_ROOT_DIR} ]; then
      /bin/mkdir ${LOG_ROOT_DIR}
    fi
    /usr/bin/find ${LOG_ROOT_DIR}/* -depth -mtime +30 | /usr/bin/xargs /bin/rm -fr
    LOG_DIR=${LOG_ROOT_DIR}/`/bin/date +%y%m%d`
    if [ ! -d ${LOG_DIR} ]; then
      /bin/mkdir ${LOG_DIR}
    fi
    LOG=${LOG_DIR}/`/bin/date +%H%M%S`_${LSNAME}_${MSGID}.txt
     
    echo $0 > "${LOG}"
     
    MNGSVR=localhost:${COSMI_MNG_MACT_MNGSVR_PORT}
    USERID=<User-id>
    PASSWD=<Password>
     
    echo ./mngsvrutil -m ${MNGSVR} -u ${USERID} -p ${PASSWD} -t ${LSNAME} -s stop server >> "${LOG}" 2>&1
    ./mngsvrutil -m ${MNGSVR} -u ${USERID} -p ${PASSWD} -t ${LSNAME} -s stop server >> "${LOG}" 2>&1
    RET=$?
    echo ${RET} >> "${LOG}"
     
    if [ $RET -eq 0 ]; then
      echo ./mngsvrutil -m ${MNGSVR} -u ${USERID} -p ${PASSWD} -t ${LSNAME} -s start server >> "${LOG}" 2>&1
      ./mngsvrutil -m ${MNGSVR} -u ${USERID} -p ${PASSWD} -t ${LSNAME} -s start server >> "${LOG}" 2>&1
      RET=$?
      echo ${RET} >> "${LOG}"
    fi
     
    exit ${RET}

(b) A sample for blocking a service unit belonging to the server issuing Management events

Reference the sample provided for blocking the service units belonging to the server from where the management event is issued, and create a sample. The sample file name and operations are as follows:

File name of a sample
  • In Windows: mActionSample_closeUnit.bat

  • In UNIX: mActionSample_closeUnit.sh

Operating the sample

When errors such as resource depletion occur in a J2EE server belonging to a service unit, block the server from where the Management event is issued.

The sample for blocking service units belonging to the server from where the Management event is issued is described below:

  • In Windows

       (Omitted)
        ...
    rem Management action sample for close unit.
     
    setlocal
     
    set LSNAME=%COSMI_MNG_MACT_LSNAME%
    set MSGID=%COSMI_MNG_MACT_MSG_ID%
    set WEBSYSTEM=%COSMI_MNG_MACT_WEBSYSTEM%
    set UNIT=%COSMI_MNG_MACT_UNIT%
     
    set CJCLDELLOG=%COSMINEXUS_HOME%\CC\client\bin\cjcldellog.bat
    set LOG_ROOT_DIR=%SystemDrive%\<MyLogDir>
    if not exist "%LOG_ROOT_DIR%" mkdir "%LOG_ROOT_DIR%"
    call "%CJCLDELLOG%" -t 30d -f "%LOG_ROOT_DIR%"
    set LOG_DIR=%LOG_ROOT_DIR%\%date:/=%
    if not exist "%LOG_DIR%" mkdir "%LOG_DIR%"
    set LOG=%LOG_DIR%\%time::=%_%LSNAME%_%MSGID%.txt
     
    echo %0 > "%LOG%"
     
    if "%WEBSYSTEM%" == "" goto :ERR
    if "%UNIT%" == "" goto :ERR
     
    set MNGSVR=localhost:%COSMI_MNG_MACT_MNGSVR_PORT%
    set UID=<User-id>
    set PWD=<Password>
     
    echo cmx_stop_target.exe -m %MNGSVR% -u %UID% -p %PWD% -mode ALL -s %WEBSYSTEM% -unit %UNIT% >> "%LOG%" 2>&1
    cmx_stop_target.exe -m %MNGSVR% -u %UID% -p %PWD% -mode ALL -s %WEBSYSTEM% -unit %UNIT% >> "%LOG%" 2>&1
    set RET=%ERRORLEVEL%
    echo %RET% >> "%LOG%"
    goto :END
     
    :ERR
    set RET=2
     
    :END
    exit %RET%
  • In UNIX

       (Omitted)
        ...
    # Management action sample for close unit.
     
    LSNAME=${COSMI_MNG_MACT_LSNAME}
    MSGID=${COSMI_MNG_MACT_MSG_ID}
    WEBSYSTEM=${COSMI_MNG_MACT_WEBSYSTEM}
    UNIT=${COSMI_MNG_MACT_UNIT}
     
    LOG_ROOT_DIR=/tmp/<MyLogDir>
    if [ ! -d ${LOG_ROOT_DIR} ]; then
      /bin/mkdir ${LOG_ROOT_DIR}
    fi
    /usr/bin/find ${LOG_ROOT_DIR} -depth -mtime +30 -mindepth 1 -exec /bin/rm -fr {} \;
    LOG_DIR=${LOG_ROOT_DIR}/`/bin/date +%y%m%d`
    if [ ! -d ${LOG_DIR} ]; then
      /bin/mkdir ${LOG_DIR}
    fi
    LOG=${LOG_DIR}/`/bin/date +%H%M%S`_${LSNAME}_${MSGID}.txt
     
    echo $0 > "${LOG}"
     
    if [ "${WEBSYSTEM}" = "" -o "${UNIT}" = "" ]; then
      exit 2
    fi
     
    MNGSVR=localhost:${COSMI_MNG_MACT_MNGSVR_PORT}
    USERID=<User-id>
    PASSWD=<Password>
     
    echo ./cmx_stop_target -m ${MNGSVR} -u ${USERID} -p ${PASSWD} -mode ALL -s ${WEBSYSTEM} -unit ${UNIT} >> "${LOG}" 2>&1
    ./cmx_stop_target -m ${MNGSVR} -u ${USERID} -p ${PASSWD} -mode ALL -s ${WEBSYSTEM} -unit ${UNIT} >> "${LOG}" 2>&1
    RET=$?
    echo ${RET} >> "${LOG}"
     
    exit ${RET}

(3) Operations of Management action execution commands

The following section describes the operation of management action execution commands: