2

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.

2 Answers 2

1

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.

2
  • I don't think we have JVM profiling enabled. That explains it. Does it have any impact to the performance of the JVM when enabled?
    – fshimaya
    Oct 15, 2019 at 20:57
  • @fshimaya We don't have benchmarks at such a granular level, so you'll need to benchmark it. The only PMI benchmark I'm aware of is that PMI Basic (enabled by default) is 2-3%
    – kgibm
    Oct 16, 2019 at 19:52
1

In addition to Scott's answer, different statistics are available depending on the level of PMI that's enabled. See the "Level" column for the JVM counters here: https://www.ibm.com/support/knowledgecenter/en/SSAW57_9.0.5/com.ibm.websphere.nd.multiplatform.doc/ae/rprf_datacounter4.html

In general, it's best to use the "Custom" level and configure exactly which metrics you want for the best performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.