To Get the Deployed Application Status in the Weblogic Domain, you can use the following python script and run it with WLST. It has nice Formatting and this post also covers "How to ignore or avoid the weblogic informational messages while running the WLST script"
Copy the Script given below to your server and save it with *.py extension
connect('weblogic','weblogic1','t3://localhost:17001') myapps=cmo.getAppDeployments() outputbuffer= outputbuffer.append("--"*40) outputbuffer.append(" \t\t\tAPPLICATION STATUS WEBLOGIC\t\t") outputbuffer.append("--"*40) outputbuffer.append (" %-50s%20s" %("APPLICATION NAME","STATUS")) outputbuffer.append("--"*40) for app in myapps: bean=getMBean('/AppDeployments/'+app.getName()+'/Targets/') targetsbean=bean.getTargets() for target in targetsbean: domainRuntime() cd('AppRuntimeStateRuntime/AppRuntimeStateRuntime') appstatus=cmo.getCurrentState(app.getName(),target.getName()) outputbuffer.append(" %-50s%20s" %(app.getName(),appstatus)) serverConfig() outputbuffer.append("--"*40) print '\n'.join(outputbuffer)
Execute the SetDomainEnv.sh (or) setWlstEnv.sh as follows ( The DOT at the front represents sourcing the script, To overwrite Local Environment Variables we must Source the script and execute it )
. /apps/oracle-weblogic/domains/mwidomain/bin/setDomainEnv.sh (or) . /apps/oracle-weblogic/wls12213/oracle_common/common/bin/setWlstEnv.sh
Invoke the AppStatus.py script with WLST ( there will be empty lines and additional messages )
java weblogic.WLST AppStatus.py
As all STDOUT is stored in python list and being displayed at the final stage. We are able to Separate Info messages and the Required Output
How to avoid Weblogic Informational Messages and Extra Lines?
Simple, If you are Unix user. just filter the output using grep command and display only the lines you want
java weblogic.WLST AppStatus.py |egrep -i "^-|^ "
If you notice clearly, we are filtering only the lines starts with Space or dashes.
There is a dedicated article about this How to Avoid WLST Information Messages and Run the scripts Silently you can take a look at
For Some Reason, If you do not want to use the List Buffer method in a python script, You can download the previous version of the script from here
Not the Secure Way!
Note*: In these scripts, we are using Clear text username and password for everyone's convenience which is not recommended.
If you want the secure way you can use UserKeyFile and UserConfigFile
Having questions, how to create these user key and user config files here you go
Hope it helps, If you like to be notified when we add a new content. Please leave your name and email id in the following subscription form ( we never spam!)