Saturday, July 19, 2014

Creating a connection to Weblogic env

Step1: Create a script as below in a text file
####################################################################
#This will connect to Weblogic, get into runtime, and get the weblogic running state.#
####################################################################
connect('haare','haare123','t3://localhost:7001')
cd('AppDeployments')
myapps=cmo.getAppDeployments()
print '----',myapps
print '----',pwd()
domainRuntime()
cd('/ServerRuntimes/myserver')
print 'the current running state is-->'+cmo.getState()
###########################
#The State can be written to a file#
###########################
f=open("d:\<filename>.txt","w")
print >>f,cmo.getState()
f.close()
#########################
#Or Appended to an existing file#
##########################

f = open("D:\filename.txt", "a")
       print >>f, cmo.getState()
f.close()

#########END OF CODE########
Step 2: Save this as a filename.py file

Step3: Open cmd and run From Command Prompt >wlst filename.py

Assumptions:The weblogic server is up and listening on port 7001
This is done on a Windows 7 64 bit env or from the server where weblogic is running
wlst's path is set in environment variable using " set path=%path%;d:/wlst;"

============================================================

Additional Notes:

  1. When you are running in domainRuntimes() then weblogic monitoring is possible.
  2. At each level we can see what commands are available to execute through ls()
  3. The ones with permission "-r--" the values can be obtained using get('<parameter>'). Example get('State').
  4. The very same commands can be put in a script and executed.

No comments:

Post a Comment