http://www.wikio.fr WebSphere And Tivoli Tricks: Jython script to show WebSphere Application Server Cluster Status

Wednesday, May 18, 2011

Jython script to show WebSphere Application Server Cluster Status

Sample usage in unix:
wsadmin.sh -lang jython -f ./show_cluster_status.py <clusterName>
-----------------------------------------------------------------
possible improvement would be to check that cluster exists and that
a cluster name has been passed is as a command line paramter.
-----------------------------------------------------------------
i = 0
clusterName = sys.argv[i]
clusterId = AdminConfig.getid("/ServerCluster:"+clusterName+"/" )
print "ClusterName is: "+clusterName
if (len(clusterId) != 0):
clusterObject = AdminControl.completeObjectName("type=Cluster,name="+clusterName+",*" )
clusterStatus = AdminControl.getAttribute(clusterObject, "state" )
print "clusterStatus="+clusterStatus
running = "websphere.cluster.running"
partialstart = "websphere.cluster.partial.start"
starting = "websphere.cluster.starting"
stopped = "websphere.cluster.stopped"
if (cmp(clusterStatus, starting) == 0):
print "starting"
sys.exit()
#endIf
if (cmp(clusterStatus, stopped) == 0):
print "stopped"
sys.exit()
#endIf
if (cmp(clusterStatus, running) == 0):
print "running"
sys.exit()
#endIf
if (cmp(clusterStatus, partialstart) == 0):
print "partialstart "
sys.exit()
#endIf

else:
print "Error"
#endElse

No comments:

Post a Comment