domain.name=7001_Plain_Domain
admin.url=t3://localhost:7001
admin.userName=weblogic
admin.password=weblogic1
totalServersToMonitor=2
server.1.url=t3://localhost:7001
server.2.url=t3://localhost:7003
Step3). Write the WLST Script “serverAdminState.py” inside “C:\WLST_AdminStateCheck” directory.
#############################################################################
#
# @author Copyright (c) 2010 - 2011 by Middleware Magic, All Rights Reserved.
#
#############################################################################
from java.io import FileInputStream
propInputStream = FileInputStream("domain.properties")
configProps = Properties()
configProps.load(propInputStream)
domainName=configProps.get("domain.name")
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")
totalServerToMonitor=configProps.get("totalServersToMonitor")
i=1
while (i <= int(totalServerToMonitor)) :
url=configProps.get("server."+ str(i)+".url")
connect(adminUserName,adminPassword,url)
serverRuntime()
state=cmo.getState()
name=cmo.getName()
if state == 'ADMIN' :
print "ALERT::::::::Server Name: " + name + " Is currently in State: " + state
try:
print 'Resuming Server: .....'
cmo.resume()
print "Server: "+name +"Moved to State : " + cmo.getState()
except:
print "NOTE:::::::::Unable to Move Server: " + name + " To good State"
else:
print ''
print ''
print "GOOD::::::::> Server Name: " + name + " Is currently in State: " + state + ' '
i = i + 1
java weblogic.WLST serverAdminState.py
Following would be the output:
java weblogic.WLST serverAdminState.py
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain '7001_Plain_Domain'.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
Location changed to serverRuntime tree. This is a read-only tree with ServerRuntimeMBean as the root.
For more help, use help(serverRuntime)
GOOD::::::::> Server Name: AdminServer Is currently in State: RUNNING
Connecting to t3://localhost:7003 with userid weblogic ...
Successfully connected to managed Server 'ManagedServer-1' that belongs to domain '7001_Plain_Domain'.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
ALERT::::::::Server Name: ManagedServer-1 Is currently in State: ADMIN
Resuming Server: .....
Server: ManagedServer-1Moved to State : RUNNING