Saturday, July 23, 2011

Wanna get the status of the applications in domain

In most of environments we have multiple applications deployed on our servers, it is diffcult to check their status when server uses high cpu utilisation. We can get the details by giving one input i.e., targetname.
Please check the below code snippet and you can change as per your requirement.
#################################################################################
#This script will get you status of the all the applications which are deployed #
#in the Domain.         #
# script get you the colored output                         #
# NOTE : You need to give target name as an input to the script                #
# Author: Krishna Sumanth Naishadam                         #
#################################################################################
import sys

connect('username','password','t3://:')
targetName=sys.argv[1]
domainConfig()
apps=cmo.getAppDeployments()
for i in apps:
 navPath1=getMBean('domainConfig:/AppDeployments/'+i.getApplicationName())
 appID=navPath1.getApplicationIdentifier()
 navPath=getMBean('domainRuntime:/AppRuntimeStateRuntime/AppRuntimeStateRuntime')
 sts=navPath.getCurrentState(appID,targetName)
 if(sts == "STATE_ACTIVE"):
  print "\033[1;32m Status of " + i.getApplicationName() + ": " + sts + "\033[1;m"
 else:
  print "\033[1;31m Status of " + i.getApplicationName() + ": " + sts + "\033[1;m"
disconnect()
exit()

domain_app_status.sh
********************

WL_HOME="
# set up common environment
. "${WL_HOME}/server/bin/setWLSEnv.sh"

CLASSPATH="${CLASSPATH}:${WL_HOME}/common/eval/pointbase/lib/pbembedded51.jar:${WL_HOME}/common/eval/pointbase/lib/pbtools51.jar:${WL_HOME}/common/eval/pointbase/lib/pbclient51.jar"
read -p "Enter Target Name : " value1

"${JAVA_HOME}/bin/java" -Xmx124m -Dprod.props.file=${WL_HOME}/.product.properties weblogic.WLST domain_app_status.py $value1 $*

Output:
======
Status of : STATE_ACTIVE (Green Color)
Status of : STATE_FAILED (Red Color)
Status of : STATE_NEW (Red Color)

Please see below screenshot for exact output

1 comment:

  1. getting error
    AttributeError: 'NoneType' object has no attribute 'getApplicationIdentifier'

    Please help.

    WL_HOME="
    should i replace with the path or coment this line as env is already source in my server
    also

    should we comment in domain_app_status.sh

    ReplyDelete