WAS v8.5 > Script the application serving environment (wsadmin) > Manage servers and nodes with scriptingQuerying server state using scripting
We can use wsadmin and scripting to query server states.
Before starting this task, wsadmin must be running. See the topic about starting the wsadmin scripting client using wsadmin.sh for more information. When querying the server state, the following command steps return a value of STARTED if the server is started. If the server is stopped, the command does not return a value.
- Identify the server and assign it to the server variable. The following example returns the server MBean that matches the partial object name string:
Jacl:
set server [$AdminControl completeObjectName cell=mycell,node=mynode, name=server1,type=Server,*]Jython:
server = AdminControl.completeObjectName('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=ManagedProcessIf the server is stopped, the completeObjectName command returns an empty string ( ' ' ).
- Query for the state attribute. In addition to using the previous step, we can also query for the server state attribute. For example:
Jacl:
$AdminControl getAttribute $server state
Jython:
print AdminControl.getAttribute(server, 'state')
The getAttribute command returns the value of a single attribute.
Example output:
STARTED
Related
Use the wsadmin scripting AdminControl object for scripted administration
Start the wsadmin scripting client using wsadmin.sh
Reference:
Commands for the AdminControl object using wsadmin.sh