简体   繁体   English

使用JMX列出Tomcat连接

[英]List Tomcat connections using JMX

Is there a way to list all connections per deployed jar in Tomcat? 有没有办法列出Tomcat中每个部署的jar的所有连接?

I found this code to list all applications: 我发现此代码列出了所有应用程序:

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://31.181.71.213:9999/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection server = jmxc.getMBeanServerConnection();
Set<ObjectName> names = server.queryNames(new ObjectName("Catalina:type=Host,*"), null);
Set<String> hostNames = new HashSet<String>();

for (ObjectName on : names)
{
    hostNames.add(on.getKeyProperty("host"));
}

for (String str : hostNames)
{
    ObjectName[] webapps = (ObjectName[]) server.getAttribute(new ObjectName("Catalina:type=Host,host=" + str), "children");
    for (ObjectName ob : webapps)
    {
        String[] appSpl = ob.getKeyProperty("name").split("//localhost");
        // webappNames.add(appSpl[1]);
        System.out.println("Deployed application " + appSpl[1]);
    }
}

But how I can also list the network connections? 但我怎么也可以列出网络连接?

Apache ActiveMQ is what you are looking for! Apache ActiveMQ正是您所需要的!

You can achieve the connection statistics using the ActiveMQ MBeans - Connection 您可以使用ActiveMQ MBeans - Connection实现连接统计

Have a look at the Apache ActiveMQ JMX 看看Apache ActiveMQ JMX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM