Technical posts/Web & WAS

webtier 12c/ OHS 12c status 확인

ODB 2017. 3. 15. 19:04

webtier 12c / OHS 12c status 확인


오라클에서 제공하는 스크립트라 별도의 설명은 없이 내용만 넣겠다


한가지 아쉬웠던건 opmnctl status -l 하면 포트까지 나왔었는데 12c는 그런 배려가 전혀 없다


그래서 cat으로 httpd.conf를 긁어 설정된 port를 확인하고 해당포트를 awk $2로 받은다음에 변수에 넣고 해당값으로 netstat을 grep 하도록 하겠다


#!/bin/sh

# --- Start Functions ---


usage()

{

        echo "Usage: $1 COMPONENT_NAME "

        echo "Where:"

        echo "  COMPONENT_NAME  - Required. System Component name"

        echo "  showErrorStack - Optional. Show error stack if provided."

}


# --- End Functions ---


if [ "$1" = "" ] ; then

        usage $0

        exit

else

        componentName="$1"

        export componentName

        shift

fi


if [ "$1" = "showErrorStack" ] ; then

        showErrorStack="true"

        export showErrorStack

else

        showErrorStack="false"

        export showErrorStack

fi


WL_HOME="/webtier/ohs1221/wlserver"


DOMAIN_HOME="/webtier/domains/base_domain"


umask 027



if [ "${showErrorStack}" = "false" ] ; then

        echo "try:" >"status.py"

        echo "  componentName = java.lang.System.getenv('componentName')" >>"status.py"

        echo "  nmConnect('webtier','webtier1','localhost','5556','base_domain')">>"status.py"

        echo "  nmServerStatus('${componentName}',serverType='OHS')" >>"status.py"

        echo "  exit()" >>"status.py"

        echo "except Exception,e:" >>"status.py"

        echo "  print 'Error:', sys.exc_info()[1]" >>"status.py"

        echo "  exit(exitcode=1)" >>"status.py"

else

        echo "componentName = java.lang.System.getenv('componentName')" >"status.py"

        echo "stopComponentInternal('${componentName}', r'${DOMAIN_HOME}')" >>"status.py"

        echo "exit()" >>"status.py"

fi


echo "Showing Status of System Component ${componentName} ..."


# Using WLST...


${WL_HOME}/../oracle_common/common/bin/wlst.sh -i status.py  2>&1

echo "HTTP"

cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/httpd.conf |grep Listen |grep -v "#"

echo "SSL"

cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/ssl.conf |grep Listen |grep -v "#"

echo "LISTEN"

http_port=`cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/httpd.conf |grep Listen |grep -v "#"| awk '{print $2}'`

https_port=`cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/ssl.conf |grep Listen |grep -v "#"| awk '{print $2}'`

netstat -an |grep ${http_port}|grep tcp

netstat -an |grep ${https_port}|grep tcp


if [ $? -ne 0 ] ; then

        exit 1

fi

if [ -f status.py ] ; then

        rm -f status.py

fi



echo "Done"


exit


굵게 처리된 곳을 자신의 환경에 맞게 잘 수정하도록 하자


결과는 아래와 같이 잘 나왔다


[webtier@centos6 bin]$ sh stat.sh webtier2

Showing Status of System Component webtier2 ...


Initializing WebLogic Scripting Tool (WLST) ...


Welcome to WebLogic Server Administration Scripting Shell


Type help() for help on available commands


Connecting to Node Manager ...

Successfully Connected to Node Manager.


RUNNING




Exiting WebLogic Scripting Tool.


HTTP

Listen 7777


SSL

Listen 4443


LISTEN

tcp        0      0 :::7777                     :::*                        LISTEN

tcp        0      0 :::4443                     :::*                        LISTEN


Done

[webtier@centos6 bin]$ sh stat.sh webtier1

Showing Status of System Component webtier1 ...


Initializing WebLogic Scripting Tool (WLST) ...


Welcome to WebLogic Server Administration Scripting Shell


Type help() for help on available commands


Connecting to Node Manager ...

Successfully Connected to Node Manager.


RUNNING




Exiting WebLogic Scripting Tool.


HTTP

Listen 81


SSL

Listen 444


LISTEN

tcp        0      0 :::81                       :::*                        LISTEN

tcp        0      0 :::44403                    :::*                        LISTEN

tcp        0      0 :::4443                     :::*                        LISTEN

tcp        0      0 :::444                      :::*                        LISTEN


Done

[webtier@centos6 bin]$ sh stat.sh webtier3

Showing Status of System Component webtier3 ...


Initializing WebLogic Scripting Tool (WLST) ...


Welcome to WebLogic Server Administration Scripting Shell


Type help() for help on available commands


Connecting to Node Manager ...

Successfully Connected to Node Manager.


RUNNING




Exiting WebLogic Scripting Tool.


HTTP

Listen 82


SSL

Listen 445


LISTEN

tcp        0      0 :::82                       :::*                        LISTEN

tcp        0      0 :::445                      :::*                        LISTEN


Done

[webtier@centos6 bin]$

 


444포트의경우 4443도 있고 44403도 있어서 같이 출력되었다 ㅜ.ㅜ

grep을 원만히 조절하면 원하는 값을 정확히 볼수 있을것이라 생각한다

필자는 이정도에서 만족하므로 더이상 수정하지 않겠다 ㅎㅎ

너무 완벽해도 피곤하니까


그럼 끝!


여기서 만족하려했으나

쓰다보니 영 심심해서 수정을 좀 했다


#!/bin/sh

# --- Start Functions ---

## Node manager info##

nUser=webtier

nPass=webtier1

nAdd=localhost

nPort=5556

nDom=base_domain

WL_HOME="/webtier/ohs1221/wlserver"

DOMAIN_HOME="/webtier/domains/base_domain"



usage()

{

        echo "Usage: $1 COMPONENT_NAME "

        echo "Where:"

        echo "  COMPONENT_NAME  - Required. System Component name"

        echo "  showErrorStack - Optional. Show error stack if provided."

}


# --- End Functions ---


if [ "$1" = "" ] ; then

        usage $0

        exit

else

        componentName="$1"

        export componentName

        shift

fi


if [ "$1" = "showErrorStack" ] ; then

        showErrorStack="true"

        export showErrorStack

else

        showErrorStack="false"

        export showErrorStack

fi


umask 027


if [ "${showErrorStack}" = "false" ] ; then

        echo "try:" >"status.py"

        echo "  componentName = java.lang.System.getenv('componentName')" >>"status.py"

        echo "  nmConnect('${nUser}','${nPass}','${nAdd}','${nPort}','${nDom}')">>"status.py"

        echo "  nmServerStatus('${componentName}',serverType='OHS')" >>"status.py"

        echo "  exit()" >>"status.py"

        echo "except Exception,e:" >>"status.py"

        echo "  print 'Error:', sys.exc_info()[1]" >>"status.py"

        echo "  exit(exitcode=1)" >>"status.py"

else

        echo "componentName = java.lang.System.getenv('componentName')" >"status.py"

        echo "stopComponentInternal('${componentName}', r'${DOMAIN_HOME}')" >>"status.py"

        echo "exit()" >>"status.py"

fi


echo "Showing Status of System Component ${componentName} ..."


# Using WLST...

isRunning=`netstat -an |grep ${nPort} | wc -l`

if [ "${isRunning}" = "1" ]; then

        echo ""

        echo ""

        printf "OHS instance ${componentName} is "

        insRunning=`${WL_HOME}/../oracle_common/common/bin/wlst.sh -i status.py  2>&1 | grep 'RUNNING\|SHUTDOWN'`

        echo "${insRunning}"

        if [ "${insRunning}" = "RUNNING" ]; then

        printf "┌───────────────┬───────────────┐\n"

        printf "│HTTP\t\t│SSL\t\t│\n"

        http=`cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/httpd.conf |grep Listen |grep -v "#"`

        https=`cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/ssl.conf |grep Listen |grep -v "#"`

        printf "├───────────────┼───────────────┤\n"

        printf "│${http}\t│${https}\t│\n"

        printf "└───────────────┴───────────────┘\n"

        echo ""

        echo "LISTEN=====================================[grep ports above]======================================================"

        http_port=`cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/httpd.conf |grep Listen |grep -v "#"| awk '{print $2}'`

        https_port=`cat  ${DOMAIN_HOME}/config/fmwconfig/components/OHS/instances/${componentName}/ssl.conf |grep Listen |grep -v "#"| awk '{print $2}'`

        echo "netstat -an |grep -w ":${http_port}"|grep tcp;netstat -an |grep -w ":${https_port}"|grep tcp "

        echo ""

        netstat -an |grep -w ":${http_port}"|grep tcp

        netstat -an |grep -w ":${https_port}"|grep tcp

        echo ""

        echo "=================================================================================================================="

        echo ""

        fi

else

        echo "NodeManager is not running with ${nPort} port"

        echo "Please, check that the server is running and accepting connections."

fi


if [ $? -ne 0 ] ; then

        exit 1

fi

if [ -f status.py ] ; then

        rm -f status.py

fi

echo "Done"

exit

 

nUser=webtier

nPass=webtier1

nAdd=localhost

nPort=5556

nDom=base_domain

WL_HOME="/webtier/ohs1221/wlserver"

DOMAIN_HOME="/webtier/domains/base_domain"

부분만 사용하는 환경에 맞게 수정하고


아래처럼 출력이 된다 ㅎㅎ


이젠 진짜 업데이트 안할것 같다.. 라고 말하지만

Listen이 여러개 선언되어 있으면 요 스크립트가 다 긁어오지 못하니 ㅜ.ㅜ array에 Listen을 여러개 넣을수 있게 바꿔야 겠다.. 언젠간..



























"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."