bla*_*ank 7 websphere jython wsadmin
我可以获得一个已安装的应用程序列表,但如何使用Jython获取状态?
Sne*_*mon 13
我不认为有任何直接的方法来获取应用程序运行状态,您可以使用以下代码从AdminControl获取对象
serverstatus = AdminControl.completeObjectName('type=Application,name='your_application_name',*')
print serverstatus
Run Code Online (Sandbox Code Playgroud)
如果serverstatus返回null,则应用程序未运行,如果应用程序正在运行,则将打印应用程序的详细信息.
以下是我根据Snehan的回答使用的内容.
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()
Run Code Online (Sandbox Code Playgroud)
样本输出
============================
Status | Application
============================
Running | DefaultApplication
Running | IBMUTC
Stopped | some-ear
Running | another-ear
============================
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17817 次 |
| 最近记录: |