Saturday, December 18, 2010

Bounce Servers with NodeManager using WLST

My online buddy asked me to publish a wlst script for Node maneger that bounces WebLogic server. Its really wonderful thought having this idea with WLST.

Have it your way
This script you can customized as per your environment.
Here you need to do the following which are instructed by buddy because I don't have NodeManager environment test this script. But strongly confident that this will work for you,
* please change the AdminServer's Listen address, Listen port in connection module.

#===========================================
# This module will starts the NodeManager
# Author: Sumanth Krishna
#========================================
def startnm():
 try:
  progress=startNodemanger()
  progress.printStatus()
 except:
  print 'FAILED TO START NODE MANAGER'
  print dumpStack()
# The module NodeManager connects to the AdminServer
def connectnm():
 try:
  progress=nmConnect(user,passwd,WLHOST,NMPORT,domainname,domainpath,plain)
  progress.printStatus()
 except:
  print 'FAILED TO CONNECT NODE MANAGER'
  print dumpStack()

# This module is for starting the AdminServer pass AdminServer name
def startAdminServer(svrName):
  try:
    nmStart(svrName)
  except:
    print "Problem starting the Admin server "+svrName

# This module for starting the managed server
def startManagedServers():
 try:

 mbeans = home.getMBeansByType("ServerLifeCycleRuntime")
 for i in mbeans:
  svrName = i.getName()
  if svrName != serverName:
   if i.getState() != "RUNNING":
    nmStart(svrName)
 except:
  print "Problem starting the managed server "+svrName

#Main functaion i.e., all functions used to call from here
if __name__== "main":
 startnm()
 connectnm()
 startAdminServer()
 startManagedServers()
       print 'DONE'

Review this script and write back comments and suggestions to me your trial outputs and issues... whatever you have with this

Good Reference Links:
1. James Bayer blog

2 comments:

Leon Dorfling said...

Hi

I am trying to use the script. I am getting a Syntax Error at mbeans = home.getMBeansByType("ServerLifeCycleRuntime") . Is there any configuration that I need to do to be able to use this.

Regards.

Leon

Pavan Bhavani Shekhar said...

Leon,

Sorry for inconvence, To reach ServerLifeCycleRuntime you must be connected,you must be on domainRuntime MBean tree.

Ref : http://wlstbyexamples.blogspot.com/2010/02/server-state-using-wlst.html

Search This Blog

Loading...

My Favorites