webspherejythonwsadmin

wsadmin getStatsObject not returning all of the metrics for JVMRuntime


I am writing a jython script that returns performance metrics for the JVMRuntimeModule. It is returning the following:

HeapSize,FreeMemory,UsedMemory,UpTime,ProcessCpuUsage

But not the following: GCCount,GCIntervalTime,GCTime,ObjectAllocateCount,ObjectFreedCount,ThreadStartedCount,ObjectMovedCount,WaitsForLockCount,ThreadEndedCount,WaitForLockTime

How do I have it return all of them?

    type = sys.argv[0]    # "JVM"
    name = sys.argv[1]    # "JVM"
    process = sys.argv[2] # "MyServer"

    objectName = "WebSphere:name=%s,process=%s,type=%s,*" % (name, process, type)
    perfName = AdminControl.completeObjectName("type=Perf,process=%s,*" % process)
    perfOName = AdminControl.makeObjectName(perfName)
    sigs = ['javax.management.ObjectName', 'java.lang.Boolean']
    coName = AdminControl.completeObjectName (objectName)
    params = [AdminControl.makeObjectName (coName), java.lang.Boolean ('false')]
    jvmObj=AdminControl.invoke_jmx (perfOName, 'getStatsObject', params, sigs)
    jvmStats = jvmObj.getStatistics()
    print jvmStats

jvmStats only contains HeapSize,FreeMemory,UsedMemory,UpTime,ProcessCpuUsage

Output:

array([name=HeapSize, ID=1, description=The total memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=BoundedRangeStatistic, lowWaterMark=262144, highWaterMark=524288, current=523264, integral=7.8067724096E10, lowerBound=262144, upperBound=524288, 
name=FreeMemory, ID=2, description=The free memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=CountStatistic, count=89475, 
name=UsedMemory, ID=3, description=The amount of used memory (in KBytes) in the Java virtual machine run time., unit=KILOBYTE, type=CountStatistic, count=433788, 
name=UpTime, ID=4, description=The amount of time (in seconds) that the Java virtual machine has been running., unit=SECOND, type=CountStatistic, count=2421377, 
name=ProcessCpuUsage, ID=5, description=The CPU Usage (in percent) of the Java virtual machine., unit=N/A, type=CountStatistic, count=0], com.ibm.ws.pmi.stat.StatisticImpl)

I would like all of them to be returned.


Solution

  • Not too familiar with this area, but I see a couple things to look at:

    1) Some of those statistics are only available with JVM profiling enabled, (as mentioned here). E.g. add a generic JVM argument: -agentlib:pmiJvmtiProfiler. See the instructions here for where to do this in the admin console.

    2) The JVM stats are nested in a tree structure (see here) so you could add this line:

    print jvmObj.getSubStats()
    

    to see the nested statistics. You can see this structure too if you go in the admin console to PMI->server and then click on the Custom link in the panel to get a tree-type of control showing all the PMI settings.

    3) Of course, you have to have the PMI stats enabled (from PMI->server , etc.), but I'm guessing you already did that.