How can I get Tomcat's connection pool stats?

a 夏天 提交于 2019-12-13 15:22:20

问题


I need to get the stats of my tomcat server's connection pool from the deployed webapp. like., active connection count, idle connection count, pool size, last wait time etc.,

I was to able to get some stats from org.apache.tomcat.dbcp.dbcp.BasicDataSource (narrowed from java.sql.DataSource through JNDI). But its not providing the stats like last connection wait time etc.,

Is there any other (better) way to retrieve these stats ?

Thanks in advance.


回答1:


We create a singleton instance (per app) of org.apache.tomcat.jdbc.pool.ConnectionPool instead of allowing Tomcat to create it. We use a servlet to display a web page with pool statistics by accessing the pool getters like getSize(), getIdle(), etc. This is useful for debugging connection problems.

The downside with this approach is that you can't use JNDI to get a connection.

I always thought there should be a standard way to get common connection pool stats.



来源:https://stackoverflow.com/questions/21280658/how-can-i-get-tomcats-connection-pool-stats

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!