Querying server state using scripting

 

Querying server state using scripting

Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.

Perform the following steps to query the server state:

  1. Identify the server and assign it to the server variable. The following example returns the server MBean that matches the partial object name string:

    • Using Jacl:
      set server [$AdminControl completeObjectName cell=mycell,node=mynode,name=server1,type=Server,*]

    • Using Jython:
      server = AdminControl.completObjectName('cell=mycell,node=mynode,name=server1,type=Server,*')
      print server

    Example output:

    WebSphere:cell=mycell,name=server1,mbeanIdentifier=server.xml#Server_1,type=Server,node=mynode,process=server1,processType=ManagedProcess 

  2. Query for the state attribute. For example:

    • Using Jacl:
      $AdminControl getAttribute $server state

    • Using Jython:
      print AdminControl.getAttribute(server, 'state')

    The getAttribute command returns the value of a single attribute. Example output:

    STARTED



Related concepts
AdminControl object for scripted administration

Related reference
Commands for the AdminControl object