2016-08-01 105 views
1

当试图获取WebSphere Application Server中的应用程序状态时,我预计会有多个返回的mbeans。但是,WAS只返回了第一个结果,并且丢弃了它们的其余部分。IBM WebSphere Application Server wsadmin仅在脚本中返回6中的第一个结果

[[email protected] ~]$ Run_wsadmin.sh -f wsadmin_Check_App_Status.py 
WASX7209I: Connected to process "dmgr" on node PRDDMGR using SOAP connector; The type of process is: DeploymentManager 
WASX7026W: String "type=Application,name=AMTApp,*" corresponds to 6 different MBeans; returning first one. 

我跑看起来像这样的脚本:

app_name = AppName 
app_status = AdminControl.completeObjectName('type=Application,name=' + app_name + ',*').split('\n') 

for status in app_status : 
    print(status) 
# end of For status in app_status 

是否有在WebSphere一些设置,或者我需要输入一些特殊的库到我的剧本?

回答

3

AdminControl.completeObjectName()

的文档使用completeObjectName命令来创建基于片段的完整的ObjectName值的字符串表示。该命令不与服务器通信以查找匹配的ObjectName值。 如果系统发现多个匹配该片段的MBean,则该命令返回第一个MBean。

因此,该函数的行为如预期。

相反
在这种情况下,这听起来像你想使用AdminControl.queryNames(),这是返回匹配您的查询结果列表建成。

例如:

app_name = AppName 
app_status = AdminControl.queryNames('type=Application,name=' + app_name + ',*').split('\n') 

for status in app_status : 
    print(status) 

来源:Commands for the AdminControl object using wsadmin scripting

相关问题