How do I determine if an application is running using wsadmin Jython script?
Asked Answered
C

4

8

I can get a list of instlled applications but how do I get the status using Jython?

Councilwoman answered 18/11, 2011 at 16:48 Comment(1)
I would also expand your question to see what the status of an application is per application server. Then we should get some more interesting answers.Eosinophil
Y
14

I dont think there is any direct method to get the application running status, You can get the object from the AdminControl using the following code

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

If serverstatus returns null, then the application is not running, if the application is running then the details of the applications would be printed.

Yeomanry answered 19/11, 2011 at 12:42 Comment(2)
Can you add in other arguments like server=WPS00 or anything like that?Eosinophil
Answered my own question. You include in the search string process=WPS00 and it'll look at specific AppServers.Eosinophil
R
6

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()

Sample output

============================
 Status |    Application
============================
Running | DefaultApplication
Running | IBMUTC
Stopped | some-ear
Running | another-ear
============================
Remittent answered 8/1, 2014 at 13:41 Comment(2)
So, my web console says the application is in a partial start, but when I use wsadmin scripting, it returns all the AppServers that its installed on, not actually showing a NULL, or blank return. Should that be happening?Eosinophil
How do I run this file? I am getting error NameError: name 'AdminApp' is not definedRickeyricki
E
4

The following IBM documentation should help:

To summarize, if the application is running on an application server, an Application MBean will be registered. In order to determine if the application is running, you can query for the presence of these MBeans.

Erato answered 18/11, 2011 at 18:39 Comment(0)
G
1

There is some more modification required in Matthieu, Cormier's script.

Here we go.

It will work in any line separator. Generally AdminApp.list() will use "\" as the line seperator

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()
Genitourinary answered 26/11, 2015 at 13:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.