JMX For Monitoring and Maintenance JA-SIG - December 4, 2005 – Atlanta, GA Eric Dalquist Division of Information Technology University of Wisconsin – Madison JA-SIG 12/4/2005 1 The Problem How to monitor and manage JVMs? • • • • Heap usage Threads Connection pools Simultaneous users JA-SIG 12/4/2005 2 Current Solutions • Garbage collector logs – Not the easiest to read – Need to have a session open to each machine • Custom monitoring code – Can’t always access interesting information – Code you have to maintain and modify JA-SIG 12/4/2005 3 The JMX Solution • • • • Java Management eXtensions Open standard (JSR-160) API and tools included with Java 5 Provides both Monitoring and Management JA-SIG 12/4/2005 4 Advantages of JMX • • • • • Standards based means little or no coding Many applications already instrumented Existing tools to connect to MBean servers Frameworks to assist in instrumentation Very little impact on server performance JA-SIG 12/4/2005 5 Instrumentation • MBeans – Management beans – JavaBean style objects – Provide information • Statistics, current state, overall summary – Provide notifications • Application events, values out of bounds – Provide management • Live configuration changes JA-SIG 12/4/2005 6 Instrumentation • MBean Server – – – – – MBeans are registered with the server Management tools connect to the server Aggregates information for tools Polls MBeans and manages data Manages MBean access rights JA-SIG 12/4/2005 7 Monitoring & Management • JMX Client – – – – Can view all exposed MBeans and properties Monitor multiple MBean servers (JVMs) Subscribe to MBean event notifications Modify writeable MBean properties JA-SIG 12/4/2005 8 JMX Clients • JConsole – Comes with Java 5 and later – Swing based desktop application • MC4J – Open source Swing based desktop application – Remembers server configuration – Custom monitoring panel capabilities JA-SIG 12/4/2005 9 JMX Clients • JManage – Web based application • Multiple users can monitor JVMs – Can connect to multiple JVMs • Organize JVMs into clusters – 2.0 beta recently released • Roadmap includes logging data to a database JA-SIG 12/4/2005 10 JConsole JA-SIG 12/4/2005 11 MC4J JA-SIG 12/4/2005 12 jManage JA-SIG 12/4/2005 13 JMX @ UW-Madison • Metrics gathering for performance tuning – Monitor heap usage and GC activity – Tune caches & resource pools during tests • Monitoring production servers – Watch for anomalies – Gather usage statistics JA-SIG 12/4/2005 14 Performance Testing • • • • • JMX adds another view of JVM metrics Heap usage for all three heap spaces Resource pool usage Cache performance and ratios Thread pool usage and sizing information JA-SIG 12/4/2005 15 JVM Summary JA-SIG 12/4/2005 16 Old Gen Heap JA-SIG 12/4/2005 17 Production Monitoring • • • • • • JConsole & MC4J are used Heap usage for memory leaks Thread pools & session counts for capacity Connection pools for database health Time spent doing garbage collection Portlet output caches & query statistics JA-SIG 12/4/2005 18 Tomcat Thread Pool JA-SIG 12/4/2005 19 Portal Session Count JA-SIG 12/4/2005 20 How To Instrument • Spring MBean exporter – Easiest way to expose JavaBeans – Only need to declare beans to be exposed – Limited in exported bean configuration • JDK MBean APIs – Powerful API for describing data to export – Non-trivial coding required JA-SIG 12/4/2005 21 JMX & JA-SIG • uPortal 3 Beans – Using Spring MBean exporter – Access to caches, thread pools, Hibernate stats • Spring based portlets – Export caching, statistics and usage data – Bookmarks Portlet – XSLT Portlet JA-SIG 12/4/2005 22 uPortal 3 RC1 Beans JA-SIG 12/4/2005 23 Bookmarks Portlet JA-SIG 12/4/2005 24 XSLT Portlet JA-SIG 12/4/2005 25