I am using Hibernate in my JBoss war, using c3p0 for connection pooling, both configured within a hibernate.cfg.xml config file in my classpath
You can monitor with Icinga/Nagios like this.
Download JMXQuery from google code. You will need to check out revision 18 like so.
svn checkout -r 18 http://jmxquery.googlecode.com/svn/trunk/ jmxquery-read-only
Download this patch. wildcard patch for c3p0
use this command to patch the source code: (make sure you are in the jmxquery-read-only/src/main directory)
patch -p0 -i wildcard_patch.diff
now download Apache Maven and extract it using this command
tar -zxvf apache-maven-*-bin.tar.gz
now cd into the jmxquery-read-only folder and run the following command (assuming the apache maven and the jmxquery are in the same folder)
../apache-maven-*/bin/mvn compile
then run the following command:
../apache-maven-3.0.3/bin/mvn package
now you should have produced a jmxquery.jar file that you can use to query the c3p0 connection pool like so: (the check_jmx file can be obtained from just downloading the jmxquery code from the google code site like normal. using this link)
check_jmx -U service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi -O com.mchange.v2.c3p0:type=PooledDataSource* -N 1 -A numBusyConnections -w 50 -c 100