问题
folks,
How I can get current status for application deployed on websphere (such as started/stopped)? I know, that I can use AdminControl.completeObjectName('type=Application,name=myApplication,*')
but if I just invoked start it is very much likely that following command will return nothing since app is not in running state yet. Same way, when I just invoked stop I want to display that app is actually stopped so that I won't change anything while app is still running. Any ideas how I can do this? Thanks.
回答1:
You can try to do this. It's a bit of work, but it's possible.
- Use application name to get the deployment target. Since you mentioned multiple nodes, I'm guessing the deployment target is going to be a cluster.
- Use the cluster to find the members of the cluster, which would be servers.
- Use the server names to check the status of each individual server.
If all servers of that cluster are started, then the application is started. If all servers of that cluster are stopped, then the application is stopped. If some are started and some are stopped, then the application is partially started.
Hope that helps.
回答2:
as for me I get application status in websphere 6.1 this way:
#--------------------------------------------------------------
# get app object name
#--------------------------------------------------------------
appObjectNames = AdminControl.queryNames('type=Application,cell=' + cellName +
',node=' + nodeName + ',process=' + serverName + ',name=' + appName + ',*')
lineSeparator = java.lang.System.getProperty('line.separator')
appObjectName = appObjectNames.split(lineSeparator)[0]
appObjectName = appObjectName.strip()
#--------------------------------------------------------------
# get application status
#--------------------------------------------------------------
if len(appObjectName) == 0:
tprint(prefix + 'application ' + appName + ' is stopped')
else:
tprint(prefix + 'application ' + appName + ' is started')
I guess this should work in WebSphere 7.0 as well.
来源:https://stackoverflow.com/questions/9910511/how-to-get-current-application-state-from-wsadmin-console-for-websphere-7-0