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>
3 comments:
Hi Jeff,
We have a requirement to log activethreadscount etc to log in the database and generate dashboard kind of report. Can you please suggest a better way to achieve this.
Thanks a lot.
Best Regards - Roy
Hi Siddhartha.
I don't recall seeing any ability for the monitoring to send that information to a database. You may be able to combine the monitoring with log4j configuration which writes log info to the database. I'm not sure how customizable this will be. I presume for the dashboard report, you'll want to have separate database columns for the timestamp and the value.
Might want to also look into retrieving the information from JMX and recording into a database. As long as you know what entries you're looking for, a simple servlet configured with quartz for scheduling could pull the information from JMX and write to the database.
The solution depends on the amount of flexibility desired and time / money (as all solutions come down to).
Thanx,
jsh
where to add this xml ?
Post a Comment