Getting a list of active sessions in Tomcat using Java

后端 未结 9 1442
醉梦人生
醉梦人生 2020-12-08 20:34

I am developing a project in Java in which I want the count of all active sessions in Tomcat. Based on that I want to see how much of those users are active and actually usi

9条回答
  •  感情败类
    2020-12-08 21:27

    You should use JMX (Java Managemnet eXtension) and query the following

    jmxObjectName:    Catalina:host=localhost,path=/,type=Manager
    jmxAttributeName: activeSessions
    

    You can use jconsole to access this data. To get jmx running see http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html

    You have lot of advantages using JMX as you get lots of other data, too. You can put it in a munin plugin and let munin monitor it and draw nice graphs to look at.

提交回复
热议问题