1 2 3 4 5 6 7 8 9 10 11 12 13
| ObjectName jvmQuery = new ObjectName("*:j2eeType=JVM,*");
Set s = mejb.queryNames(jvmQuery, null);
ObjectName jvmMBean = (ObjectName) s.iterator().next();
boolean hasStats = ((Boolean) mejb.getAttribute(jvmMBean,
"statisticsProvider")).booleanValue();
if (hasStats) {
JVMStats stats = (JVMStats) mejb.getAttribute(jvmMBean,
"stats");
String[] statisticNames = stats.getStatisticNames();
if (Arrays.asList(statisticNames).contains("heapSize")) {
System.out.println("Heap size: " + stats.getHeapSize());
}
} |
Partager