Wednesday, May 26, 2010

Application Status Checking with WLST

def appStatus(server_name):
       try:
           print '---------------------- Application status---------------------'
           mBeans=adminHome.getMBeansByType("ApplicationRuntime")
           for bean in mBeans:
               if server_name != bean.getObjectName().getLocation():
                   continue
               components= bean.lookupComponents()
               for componentRTList in components:
                   #ejbRTList=componentRTList.getMBeansByType("EJBComponentRuntime")
                   app = componentRTList.getParent().getName()
                   istate=componentRTList.getDeploymentState()
                   if istate == 0:
                       istate='UNPREPARED'
                   if istate == 1:
                       istate='PREPARED'
                   if istate == 2:
                       istate='ACTIVE'
                   if istate == 3:
                       istate='NEW'

                   print "%65s %65s %7s" % (str(componentRTList.getName()), app, istate)

       except:
           print "This Server has no Applications"

No comments: