try {
MBeanServerConnection mserver = conn.getMServer();
System.out.println("MBean server connected");
MBeanGCMonitor rmon = new MBeanGCMonitor(mserver);
MBeanGCMonitor pmon = new MBeanGCMonitor(mserver);
final MBeanGCMonitor fmon = new MBeanGCMonitor(mserver);
Thread freport = new Thread() {
@Override
public void run() {
System.out.println("\nTotal");
System.out.println(fmon.calculateStats());
}
};
Runtime.getRuntime().addShutdownHook(freport);
long interval = 60000;
long deadline = System.currentTimeMillis() + interval;
System.out.println("Collecting GC stats ...");
while(true) {
while(System.currentTimeMillis() < deadline) {
String report = rmon.reportCollection();
if (report.length() > 0) {
System.out.println(report);
}
Thread.sleep(50);
}
deadline += interval;
System.out.println();
System.out.println(pmon.calculateStats());
System.out.println();
pmon = new MBeanGCMonitor(mserver);
if (System.in.available() > 0) {
return;
}
}
} catch (Exception e) {