2014. 8. 19. 16:33

Server State using WLST

While trouble shooting administrator need to check the status of all server instances. This is the basic need when the all the servers are in bounced for production code move. This same script can be applicable for the pre-production or staging environment too. WLST provides the built-in methods, which gives the status of the Server instance or servers in a Cluster. Here we will deal with individual instance wise data.

WebLogic Server Life cycle state diagram
ServerLIfecycleRuntime Mbean tree


Using above shown MBean hierarchy we can fetch the all WebLogic domain server instance's states. If your production WebLogic domain consists of two digit (eg. 60 instances) or three digit number (eg. 120 instances) of managed server then, it is difficult to see all server’s state at once. Weblogic Administration console is unable to show all the servers in the domain on a single page. Navigating in between also a time eating process so think! think better way!! WLST has the solution.

To get the status of all servers in the domain can be obtained with the following steps
1. Connect to the Admin Server
2. Fetch the server list from the domain runtime MBean
3. Iterate the loop and get the state of each managed server with Server Life Cycle Runtime MBean
4. Repeat if required the step 3 as per the user input
5. Finally disconnect

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
##################################################
# This script is used to check the status of all WL instances including the admin
###########################################################
def conn():
UCF='/path/.AdminScripts/userConfigFile.sec'
UKF='/path/.AdminScripts/userKeyFile.sec'
try:
connect(userConfigFile=UCF, userKeyFile=UKF, url=admurl)
except ConnectionException,e:
print '\033[1;31m Unable to find admin server...\033[0m'
exit()

 

 
def ServrState():
print 'Fetching state of every WebLogic instance'
#Fetch the state of the every WebLogic instance
for name in serverNames:
  cd("/ServerLifeCycleRuntimes/" + name.getName())
  serverState = cmo.getState()
  if serverState == "RUNNING":
    print 'Server ' + name.getName() + ' is :\033[1;32m' + serverState + '\033[0m'
  elif serverState == "STARTING":
    print 'Server ' + name.getName() + ' is :\033[1;33m' + serverState + '\033[0m'
  elif serverState == "UNKNOWN":
    print 'Server ' + name.getName() + ' is :\033[1;34m' + serverState + '\033[0m'
  else:
    print 'Server ' + name.getName() + ' is :\033[1;31m' + serverState + '\033[0m'
quit()
def quit():
print '\033[1;35mRe-Run the script HIT any key..\033[0m'
Ans = raw_input("Are you sure Quit from WLST... (y/n)")
if (Ans == 'y'):
disconnect()
stopRedirect()
exit()
else:
ServrState()

 

if __name__== "main":
redirect('./logs/Server.log', 'false')
conn()
serverNames = cmo.getServers()
domainRuntime()
ServrState()

'Weblogic' 카테고리의 다른 글

WLST Thread Count  (0) 2014.08.20
WebLogic Scripting Tool (WLST) Overview  (0) 2014.08.19
JDBC Monitoring  (0) 2014.08.19
weblogic coherence  (0) 2014.08.19
weblogic status check  (0) 2014.08.18
Posted by 아도니우스