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

后端 未结 4 1076
小鲜肉
小鲜肉 2020-12-15 12:32

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

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 13:10

    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
    ============================
    

提交回复
热议问题