// Path: src/main/java/org/mycat/web/jmonitor/JMConnBean.java
// public class JMConnBean {
// 
//     private JMXConnector connector;
//     private String name;
//     private String host;
//     private String user;
//     private String pwd;
//     private int port;
// 
//     public JMXConnector getConnector() {
//         return connector;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public void setConnector(JMXConnector connector) {
//         this.connector = connector;
//     }
// 
//     public String getHost() {
//         return host;
//     }
// 
//     public void setHost(String host) {
//         this.host = host;
//     }
// 
//     public String getUser() {
//         return user;
//     }
// 
//     public void setUser(String user) {
//         this.user = user;
//     }
// 
//     public String getPwd() {
//         return pwd;
//     }
// 
//     public void setPwd(String pwd) {
//         this.pwd = pwd;
//     }
// 
//     public int getPort() {
//         return port;
//     }
// 
//     public void setPort(int port) {
//         this.port = port;
//     }
// 
// }


import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.Thread.State;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import javax.management.MBeanServer;
import javax.management.MBeanServerConnection;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mycat.web.jmonitor.JMConnBean;
import org.mycat.web.service.JMConnManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.management.OperatingSystemMXBean;
            data.put("classLoadedNow", cBean.getLoadedClassCount());
            data.put("classUnloadedAll", cBean.getUnloadedClassCount());
            data.put("classLoadedAll", cBean.getTotalLoadedClassCount());
            data.putAll(props);

            JSONObject json = new JSONObject(true);
            json.putAll(data);
            return json;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @RequestMapping("/doGC")
	@ResponseBody
    public String doVMGC(HttpServletRequest request) {
        try {
            String app = request.getParameter("app");
            JMConnManager.getMemoryMBean(app).gc();
            return "success";
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @RequestMapping("/doHeapDump")
	@ResponseBody
    public JSONObject doHeapDump(HttpServletRequest request) {
        try {
            String app = request.getParameter("app");
// Path: src/main/java/org/mycat/web/jmonitor/JMConnBean.java
// public class JMConnBean {
// 
//     private JMXConnector connector;
//     private String name;
//     private String host;
//     private String user;
//     private String pwd;
//     private int port;
// 
//     public JMXConnector getConnector() {
//         return connector;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public void setConnector(JMXConnector connector) {
//         this.connector = connector;
//     }
// 
//     public String getHost() {
//         return host;
//     }
// 
//     public void setHost(String host) {
//         this.host = host;
//     }
// 
//     public String getUser() {
//         return user;
//     }
// 
//     public void setUser(String user) {
//         this.user = user;
//     }
// 
//     public String getPwd() {
//         return pwd;
//     }
// 
//     public void setPwd(String pwd) {
//         this.pwd = pwd;
//     }
// 
//     public int getPort() {
//         return port;
//     }
// 
//     public void setPort(int port) {
//         this.port = port;
//     }
// 
// }


// Path: src/main/java/org/mycat/web/action/JMServer.java
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.Thread.State;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import javax.management.MBeanServer;
import javax.management.MBeanServerConnection;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mycat.web.jmonitor.JMConnBean;
import org.mycat.web.service.JMConnManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.management.OperatingSystemMXBean;

            data.put("classLoadedNow", cBean.getLoadedClassCount());
            data.put("classUnloadedAll", cBean.getUnloadedClassCount());
            data.put("classLoadedAll", cBean.getTotalLoadedClassCount());
            data.putAll(props);

            JSONObject json = new JSONObject(true);
            json.putAll(data);
            return json;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @RequestMapping("/doGC")
	@ResponseBody
    public String doVMGC(HttpServletRequest request) {
        try {
            String app = request.getParameter("app");
            JMConnManager.getMemoryMBean(app).gc();
            return "success";
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @RequestMapping("/doHeapDump")
	@ResponseBody
    public JSONObject doHeapDump(HttpServletRequest request) {
        try {
            String app = request.getParameter("app");
            JMConnBean bean = JMConnManager.getApps().get(app);