In most of WebLogic domain environments we might have seen multiple applications deployed on WebLogic servers. It is difficult to check their status when server uses high CPU utilization. We can get the complete details by giving one input i.e., target-name.
We use navigate MBean tree more frequently while using interactive mode of WLST and in scripting. Here we can call any attribute from any MBean tree by using colon ':' at the MBean tree root. Here we go with a sample of for you who struggling to understand navigate each and every time.
Please check the below code snippet and you can change as per your requirement.
############################################################# """ This script will get you status of the applications which are deployed in your WebLogic Domain. script get you the colorful output NOTE : You need to give target name as an input to the script Author: Krishna Sumanth Naishadam """ ############################################################## import sys connect('username','password','t3://wl_admin_host:wl_admin_port') 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 $*
The lifecycle of deployment process happen in the following way:
The following Colors I had chosen for reflecting what state for a application on a server.
======
Status of APPNAME1: STATE_ACTIVE (Green Color)
Status of APPNAME2: STATE_FAILED (Red Color)
Status of APPNAME3: STATE_NEW (Red Color)
Please see below screenshot for exact output
What if the deployment state is in New/Admin/Prepared state
ReplyDeleteAttributeError: 'NoneType' object has no attribute 'getApplicationIdentifier'
ReplyDelete