Map<String, String> props = new HashMap<String, String>();
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
ThreadMXBean threads = ManagementFactory.getThreadMXBean();
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
//
// print ServiceMix informations
//
maxNameLen = 25;
io.out.println("ServiceMix");
printValue("ServiceMix home", maxNameLen, System.getProperty("servicemix.home"));
printValue("ServiceMix base", maxNameLen, System.getProperty("servicemix.base"));
printValue("ServiceMix version", maxNameLen, branding.getVersion());
io.out.println();
io.out.println("JVM");
printValue("Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
printValue("Vendor", maxNameLen, runtime.getVmVendor());
printValue("Uptime", maxNameLen, printDuration(runtime.getUptime()));
try {
com.sun.management.OperatingSystemMXBean sunOs = (com.sun.management.OperatingSystemMXBean) os;
printValue("Process CPU time", maxNameLen, printDuration(sunOs.getProcessCpuTime() / 1000000));
printValue("Total compile time", maxNameLen, printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
} catch (Throwable t) {}
io.out.println("Threads");
printValue("Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
printValue("Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
printValue("Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
printValue("Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
io.out.println("Memory");
printValue("Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
printValue("Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
printValue("Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
printValue("Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = " + printDuration(gc.getCollectionTime());
printValue("Garbage collector", maxNameLen, val);
}