All Server States using WLST

This is an extension to my earlier post which gives the runtime attributes about the alive servers.

https://weblogic-wonders.com/weblogic/2011/03/16/weblogic-server-runtime-using-wlst/

However there could be scenarios where you might want to keep a track of all the server states like RUNNING, SHUTDOWN  etc  in the domain.

The below WLST script provides a list of all the servers in the domains and their respective server states. To check the servers which are in shutdown state.

Steps:-

1. Script to monitor all the Server States in the domain.

a. Save the below script AllServerStatus.py on to your local machine.

 

username = 'weblogic'

password = 'weblogic1'

URL='t3://localhost:7001'

connect(username,password,URL)

domainConfig()

serverList=cmo.getServers();

domainRuntime()

cd('/ServerLifeCycleRuntimes/')

for server in serverList:

name=server.getName()

cd(name)

serverState=cmo.getState()

if serverState=='SHUTDOWN':

print '**** Shutdown Servers ****'

print 'Server *****'+ name +'***** State *****'+serverState

break

print 'Server *****'+ name +'***** State *****'+serverState

cd('..')

 

 

2. Execute the WLST Script

a.  Set the CLASSPATH by running the setDomainEnv script from the

Alternatively you can set the CLASSPATH by specifying the –cp argument while executing the WLST Script

For Ex:  java –cp $BEA_HOME/wlserver_10.3/server/lib/weblogic.jar  weblogic.WLST AllServerStatus.py

 

Downloads

You can download the WLST script from the below link.

serverStateAll.py

Note: Save the script as AllServerStatus.py

References:

http://download.oracle.com/docs/cd/E11035_01/wls100/config_scripting/monitoring.html

Regards,

Wonders Team.

2 comments

Comments are closed.