Example: Migrating - Pinging running servers for the current state
The purpose of this task is to determine if a server is running. The following examples demonstrate how to ping running servers in WebSphere Application Server V4.0 and V5.0:
- wscp V4.0
set servers [ApplicationServer list] foreach server $servers { set result ApplicationServer show $server -attribute {CurrentState} puts "state for server $server: $result" }- wsadmin V5.0
In the WebSphere Application Server V5.0 configuration and control commands are separate.
set servers [$AdminConfig list Server] foreach server $servers { set objName [$AdminConfig getObjectName $server] if {[llength $objName] == 0} { puts "server $server is not running" } else { set result [$AdminControl getAttribute $objName state] puts "state for server $server: $result" } }The first line of this example obtains a list of all servers defined in the configuration. You can interrogate this data to determine the running servers. If the server is not running, nothing is returned from the getObjectName command on the AdminConfig object. If the server is running, ask for its state attribute. If the Mbean is there, the server is running and the state is STARTED. It is possible, however, for the state to be something other than STARTED, for example, STOPPING.