0

尝试制作一个非常简单的 jython 脚本来从 websphere 获取基本的 PMI 数据。获取诸如空闲堆等 JVM 数据很简单(并且有效)

perfName = AdminControl.completeObjectName ('type=Perf,process=PTEIRMW_APPSERVER801,*')
perfOName = AdminControl.makeObjectName (perfName)
jvmName = AdminControl.completeObjectName ('type=JVM,process=PTEIRMW_APPSERVER801,*')
params = [AdminControl.makeObjectName (jvmName), java.lang.Boolean ('false')]
sigs = ['javax.management.ObjectName', 'java.lang.Boolean']
AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)

但后来我尝试为 WebContainer 线程池做类似的事情,但它失败了

threadPoolName = AdminControl.completeObjectName('name=WebContainer,type=ThreadPool,process=PTEIRMW_APPSERVER801,*')
threadPoolOName = AdminControl.makeObjectName (threadPoolName)
params = [AdminControl.makeObjectName (threadPoolName), java.lang.Boolean ('false')]
sigs = ['javax.management.ObjectName', 'java.lang.Boolean']
AdminControl.invoke_jmx (threadPoolOName, 'getStatsObject', params, sigs)

错误是

WASX7015E: 异常运行命令:“AdminControl.invoke_jmx (threadPoolOName, 'getStatsObject', params, sigs)”;异常信息:javax.management.MBeanException javax.management.ServiceNotFoundException:操作getStatsObject不在ModelMBeanInfo中

有任何想法吗?我特别只想要 WebContainer 线程池(最好只有活动线程......但我可以稍后过滤掉它)

4

2 回答 2

1

您需要stats从该 MBean 检索属性:

on = AdminControl.queryNames('*,name=WebContainer,type=ThreadPool,process=PTEIRMW_APPSERVER801')
print AdminControl.getAttribute_jmx(AdminControl.makeObjectName(on), 'stats')

相同的功能,这次使用 WDR 库 ( http://wdr.github.io/WDR/ )

print getJMXMBean1(type='ThreadPool', name='WebContainer', process='PTEIRMW_APPSERVER801').stats

坦白:我是 WDR 的贡献者之一。

于 2013-09-30T21:47:37.367 回答
0

答案结果如下(清理和更通用的版本):

#Get the AppServer from parameter
appServer = sys.argv[0]

perfName = AdminControl.completeObjectName ('type=Perf,process='+appServer+',*')
perfOName = AdminControl.makeObjectName (perfName)
sigs = ['javax.management.ObjectName', 'java.lang.Boolean']

# Getting the JVM Data
jvmName = AdminControl.completeObjectName ('type=JVM,process='+appServer+',*')
params = [AdminControl.makeObjectName (jvmName), java.lang.Boolean ('false')]
print AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)

# Getting the threadpool data

threadPoolName = AdminControl.completeObjectName('name=WebContainer,type=ThreadPool,process='+appServer+',*')
params = [AdminControl.makeObjectName (threadPoolName), java.lang.Boolean ('false')]
print AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)

但我也测试了@Martin Plonkas 的答案,它也有效

于 2013-10-01T09:57:51.120 回答