Querying cluster state using scripting

You can query cluster states using the wsadmin tool and scripting.

Before you begin

Before starting this task, the wsadmin tool must be running. See the topic about starting the wsadmin scripting client using wsadmin scripting for more information.

About this task

Perform the following steps to query cluster state:

Procedure

  1. Identify the Cluster MBean and assign it to the cluster variable.
    • Using Jacl:
      set cluster [$AdminControl completeObjectName cell=mycell,type=Cluster,name=cluster1,*]
    • Using Jython:
      cluster = AdminControl.completeObjectName('cell=mycell,type=Cluster,name=cluster1,*')
      print cluster
    This command returns the Cluster MBean.
    Example output:
    WebSphere:cell=mycell,name=cluster1,mbeanIdentifier=Cluster,type=Cluster,process=cluster1
  2. Query the cluster state.
    • Using Jacl:
      $AdminControl getAttribute $cluster state
    • Using Jython:
      AdminControl.getAttribute(cluster, 'state')
    This command returns the value of the run-time state attribute.