To facilitate recording of these statistics when using JBoss, JBoss has included the ability to log/monitor JMX Mbean values. And it's not difficult to install. Once values are being logged, you no longer have to continue refreshing the JMX console to see the values updated.
For installing and monitoring of your web application(s), perform the following steps:
- Copy monitor XML files into $JBOSS/server/server_name/deploy
- Copy $JBOSS/docs/examples/jmx/logging-monitor/lib/logging-monitor.jar into $JBOSS/server/server_name/lib
- Create monitor XML files to monitor JMX MBeans (samples below)
- DB connections
- In use
- Available
- Max Connections In Use
- JVM activity
- Heap size
- Threads
DB Connection Monitoring Sample
Here's the XML necessary to monitor a JDBC connection pool (XML comments omitted)
Here's the XML necessary to monitor a JDBC connection pool (XML comments omitted)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server PUBLIC
"-//JBoss//DTD MBean Service 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
<server>
<mbean code="org.jboss.services.loggingmonitor.LoggingMonitor"
name="jboss.monitor:type=LoggingMonitor,name=MY-DSMonitor">
<attribute name="Filename">${jboss.server.home.dir}/log/my-ds.log</attribute>
<attribute name="AppendToFile">false</attribute>
<attribute name="RolloverPeriod">DAY</attribute>
<attribute name="MonitorPeriod">10000</attribute>
<attribute name="MonitoredObjects">
<configuration>
<monitoredmbean name="jboss.jca:name=MY-DS,service=ManagedConnectionPool"
logger="jca.my-ds">
<attribute>InUseConnectionCount</attribute>
<attribute>AvailableConnectionCount</attribute>
<attribute>ConnectionCreatedCount</attribute>
<attribute>ConnectionDestroyedCount</attribute>
<attribute>MaxConnectionsInUseCount</attribute>
</monitoredmbean>
</configuration>
</attribute>
<depends>jboss.jca:name=MY-DS,service=ManagedConnectionPool</depends>
</mbean>
</server>