天天看点

AM池监控打印

AM池信息开始一直是个头痛的东西,现提供一个方法用于查看AM池的状态信息:

public String printAmPool() {
        PoolMgr poolMgr = PoolMgr.getInstance();
        // get the pools managed
        Enumeration keys = poolMgr.getResourcePoolKeys();
        System.out.println(keys);
        if (keys != null) {
            if (keys.hasMoreElements()) {

 
                String poolname = (String)keys.nextElement();
                System.out.println("AM pool name: " + poolname);
               
                ApplicationPool pool =
                    (ApplicationPool)poolMgr.getResourcePool(poolname);
              
        
                PrintWriter out = new PrintWriter(System.out, true);
                pool.dumpPoolStatistics(new PrintWriter(out));
                out.flush();
            }
        }
        return null;
    }