如何获得Tomcat的连接池统计信息? [英] How can I get Tomcat's connection pool stats?

查看:100
本文介绍了如何获得Tomcat的连接池统计信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从部署的Web应用程序中获取tomcat服务器的connection pool的统计信息. 例如,活动连接计数空闲连接计数池大小最后等待时间等,

我本来可以从org.apache.tomcat.dbcp.dbcp.BasicDataSource (narrowed from java.sql.DataSource through JNDI)获得一些统计信息.但是它没有提供上次连接等待时间等统计信息,

还有其他(更好)的方式来检索这些统计信息吗?

谢谢.

解决方案

我们创建org.apache.tomcat.jdbc.pool.ConnectionPool的单个实例(每个应用程序),而不是允许Tomcat创建它.通过访问诸如getSize(),getIdle()之类的池getter,我们使用servlet来显示带有池统计信息的网页.这对于调试连接问题很有用.

这种方法的缺点是您不能使用JNDI建立连接.

我一直认为应该有一种获取通用连接池统计信息的标准方法.

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.

解决方案

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.

这篇关于如何获得Tomcat的连接池统计信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆