Search code examples
performancewebspherejythonwebsphere-8

Using jython to obtain webcontainer from WebSphere PMI data


Trying to make a really simple jython script to obtain basic PMI data from websphere. Obtaining JVM data such as free heap etc is simple (and works)

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)

But then I try and do something similar for the WebContainer threadpool and it fails

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)

The error is

WASX7015E: Exception running command: "AdminControl.invoke_jmx (threadPoolOName, 'getStatsObject', params, sigs)"; exception information: javax.management.MBeanException javax.management.ServiceNotFoundException: Operation getStatsObject not in ModelMBeanInfo

Any ideas? I specifically ONLY want the WebContainer threadpool (and preferably only active threads... but I can filter that out later)


Solution

  • The answer turns out to be as follows (cleaned up and more generic version):

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

    But I also tested out @Martin Plonkas answer and it works too