Package org.gridkit.jvmtool

Examples of org.gridkit.jvmtool.MBeanCpuUsageReporter


    public void run() {
     
      try {
        MBeanServerConnection mserver = connInfo.getMServer();
       
        final MBeanCpuUsageReporter tmon = new MBeanCpuUsageReporter(mserver);
        if (connInfo.getPID() != null) {
            try {
                long pid = connInfo.getPID();
                PerfCounterGcCpuUsageMonitor pm = new PerfCounterGcCpuUsageMonitor(pid);
                tmon.setGcCpuUsageMonitor(pm);
            }
            catch(Exception e) {
                // ignore
            }
        }
       
        tmon.setTopLimit(topNumber);
       
        if (threadFilter != null) {
          tmon.setThreadFilter(GlobHelper.translate(threadFilter, "\0"));
        }
       
        if (sortOrder != null) {
          Collections.reverse(sortOrder);
          for(String tag: sortOrder) {
            if ("SYS".equals(tag)) {
              tmon.sortBySysCpu();
            }
            else if ("USER".equals(tag)){
              tmon.sortByUserCpu();
            }
            else if ("CPU".equals(tag)){
              tmon.sortByTotalCpu();
            }
            else if ("ALLOC".equals(tag)){
              tmon.sortByAllocRate();
            }
            else if ("NAME".equals(tag)){
              tmon.sortByThreadName();
            }
            else {
              SJK.failAndPrintUsage("Invalid order option '" + tag + "'");
            }
          }
        }
       
        long deadline = System.currentTimeMillis() + Math.min(reportIntervalMS, 10 * samplerIntervalMS);
        tmon.report();
        System.out.println("Monitoring threads ...");
        while(true) {
          while(System.currentTimeMillis() < deadline) {
            Thread.sleep(samplerIntervalMS);
          }
          deadline += reportIntervalMS;
          System.out.println();
          System.out.println(tmon.report());
          System.out.println();
          if (System.in.available() > 0) {
            return;
          }
        }
View Full Code Here

TOP

Related Classes of org.gridkit.jvmtool.MBeanCpuUsageReporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.