Hi,
The following example will list all applications running. In this case, I have 4 applications.
Invoking WLST script
------------------------
java weblog.WLST listAppStatus.py
t3://localhost:7001
listAppStatus.py
------------------
def checkWlsApplicationState(serverURL):
clusterCheck = ""
#target indicates if it a cluster or admin server.
#In this case, AdminServer is the name of my adminserver.
#WLS defeault is myServer
target = ""
try:
connect('weblogic', 'weblogic' ,url=serverURL)
except:
dumpStack()
disconnect()
cd("AppDeployments")
myapps = ls(returnMap='true')
cd("../Servers")
domainName = cmo.getName()
cd("AdminServer")
slcBean = cmo.lookupServerLifeCycleRuntime()
status = slcBean.getState()
cd("../../")
try:
cd("Clusters/" + domainName + "_cluster")
clusterCheck = 0
except:
clusterCheck = 1
if clusterCheck == 0:
print 'Domain ' + domainName + ' is Clustered'
target = domainName + '_cluster'
else:
print 'Domain ' + domainName + ' is Not Clustered'
target = 'AdminServer'
print ''
domainRuntime()
cd("AppRuntimeStateRuntime/AppRuntimeStateRuntime")
print '-------------------------------------------------------------------------------'
print 'Application Name Intended State Current State'
print '-------------------------------------------------------------------------------'
appIndex=0
for applicationName in myapps:
intendedState = cmo.getIntendedState(applicationName, target)
currentState = cmo.getCurrentState(applicationName, target)
if appIndex == 0:
print applicationName + ' ' + intendedState + ' ' + currentState
elif appIndex == 1:
print applicationName + ' ' + intendedState + ' ' + currentState
elif appIndex == 2:
print applicationName + ' ' + intendedState + ' ' + currentState
elif appIndex == 3:
print applicationName + ' ' + intendedState + ' ' + currentState
appIndex = appIndex + 1
print '-------------------------------------------------------------------------------'
disconnect()
#Argument 1 is Admin URL
#For example:
t3://localhost:7001
checkWlsApplicationState(sys.argv[1])
# End of WLST
HTH,
Tom