How to determine if an application is running using the wsadmin Jython script?

I can get a list of instlled applications, but how to get status using Jython?

+4
source share
4 answers

I do not think that there is any direct method for obtaining the status of the application. You can get the object from AdminControl using the following code

serverstatus = AdminControl.completeObjectName('type=Application,name='your_application_name',*') print serverstatus 

If serverstatus returns null, the application does not work, if the application is running, then application details will be printed.

+11
source

The following IBM documentation should help:

To summarize, if the application is running on the application server, Application MBean will be registered. To determine if the application is running, you can request the availability of these MBeans.

+4
source

Here is what I use based on Snehan's answer.

 import string def getAppStatus(appName): # If objectName is blank, then the application is not running. objectName = AdminControl.completeObjectName('type=Application,name=' + appName + ',*') if objectName == "": appStatus = 'Stopped' else: appStatus = 'Running' return appStatus def appStatusInfo(): appsString = AdminApp.list() appList = string.split(appsString, '\r\n') print '============================' print ' Status | Application ' print '============================' # Print apps and their status for x in appList: print getAppStatus(x) + ' | ' + x print '============================' appStatusInfo() 

Output example

 ============================ Status | Application ============================ Running | DefaultApplication Running | IBMUTC Stopped | some-ear Running | another-ear ============================ 
+4
source

In the Matthieu, Cormier script there are a few more changes.

Here we go.

It will work in any line separator. Normally AdminApp.list () will use "\" as a line separator

 import string def getAppStatus(appName): # If objectName is blank, then the application is not running. objectName = AdminControl.completeObjectName('type=Application,name='+ appName+',*') if objectName == "": appStatus = 'Stopped' else: appStatus = 'Running' return appStatus def appStatusInfo(): Apps=AdminApp.list().split(java.lang.System.getProperty("line.separator")) print '============================' print ' Status | Application ' print '============================' # Print apps and their status for x in Apps: print "X value", x print getAppStatus(x) + ' | ' + x print '============================' appStatusInfo() 
+1
source

Source: https://habr.com/ru/post/1381933/


All Articles