JMX: Get The Most Out Of This Unsung Hero

Transcription

JMX: Get the Most out ofthis Unsung HeroTom LubinskiChief Technical Officertlubinski@sl.comSL CorporationCorte Madera, CA8 November, 2012 2012 SL Corporation. All Rights Reserved.1 2012 SL Corporation. All Rights Reserved.

AgendaIntroduction to SL CorporationJMX: A little backgroundJMX: How it can helpQ&A 2012 SL Corporation. All Rights Reserved.2 2012 SL Corporation. All Rights Reserved.

Who is SL and what is RTView ?Why should I listen to you about JMX ? 2012 SL Corporation. All Rights Reserved.3 2012 SL Corporation. All Rights Reserved.

SL Corporation Extensivebackground in realtime applicationmonitoringCritical Tax SeasonApplications at IntuitLarge volumes ofdynamic dataVisualizationtechnologiesOOCL World WideShipment TrackingSpecialists inApplication /Middleware, esp.TIBCO 2012 SL Corporation. All Rights Reserved.4 2012 SL Corporation. All Rights Reserved.

RTView Enterprise MonitorCollects, Analyzes, and Visualizes data from different sources, many using JMXRTViewEnterprise MIBMWebSphereOracleCoherenceTIBCOEMS eGlassfish and many more 2012 SL Corporation. All Rights Reserved.5 2012 SL Corporation. All Rights Reserved.

RTView Enterprise MonitorHigh-Level Application Summary ViewsDrilldown to individual components to investigate problems 2012 SL Corporation. All Rights Reserved.6 2012 SL Corporation. All Rights Reserved.

Why should I care about JMX ?(it’s kind of boring, actually )Monitoring is critical for complex apps Do you want to re-invent the wheel ?SL has found JMX to be excellent model as we hope you see in this presentation 2012 SL Corporation. All Rights Reserved.7 2012 SL Corporation. All Rights Reserved.

Whence JMX Need for collecting monitoring informationRoots in agent technology, like TIBCO HawkJMX 1.1 then 1.2External in Java 1.4, but automatic in 1.5 2012 SL Corporation. All Rights Reserved.8 2012 SL Corporation. All Rights Reserved.

Why JMX “Standards”Standardize monitoring and managementStandard system-independent data typesStandard naming / access mechanism 2012 SL Corporation. All Rights Reserved.9 2012 SL Corporation. All Rights Reserved.

Typical Monitoring Approaches None at all very commonOutput log filesWrite to DatabaseSend JMS MessageCustom TCP or Web Service transportJMX Makes it easy and standard ! 2012 SL Corporation. All Rights Reserved.10 2012 SL Corporation. All Rights Reserved.

Confession Selfish MotivesUnclean ThoughtsWe lust for you to produce more monitoring data - easily !We want you to use standards So RTView can collect data easily, analyze it, and visualize it and provide useful, actionable information for you 2012 SL Corporation. All Rights Reserved.11 2012 SL Corporation. All Rights Reserved.

Examples of Standard JMX DataEvery JVM produces CPU, Memory, Thread, GC information 2012 SL Corporation. All Rights Reserved.12 2012 SL Corporation. All Rights Reserved.

Examples of Standard JMX DataTomcat produces Session data, Request Counts, and Response Time forentire server and every servlet 2012 SL Corporation. All Rights Reserved.13 2012 SL Corporation. All Rights Reserved.

Where JMX Data can be CollectedMiddleware and Application Tiers 2012 SL Corporation. All Rights Reserved.14 2012 SL Corporation. All Rights Reserved.

How can I get my Apps to produce data likeTomcat or other middleware ?Learn to use JMX The right way ! 2012 SL Corporation. All Rights Reserved.15 2012 SL Corporation. All Rights Reserved.

What is the so-called right way to use JMX ?1) Abstract Monitoring Model2) Simple Data Model3) Pluggable Transport Mechanism 2012 SL Corporation. All Rights Reserved.16 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelMonitoring is observing !Management is commandingIsolate monitoring / management code from applicationcode 2012 SL Corporation. All Rights Reserved.17 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelCommunication should be one-way !Application shouldn’t know it is being monitored MonitoringCodeExecuteCommandsObserve internalstructureswhich should bethere already !ApplicationCode 2012 SL Corporation. All Rights Reserved.18 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelOnly one requirement to use JMX:Application must indicate it is observable and set up theobserverModularity is important ! Organize well from start !More data structures more complexity 2012 SL Corporation. All Rights Reserved.19 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelApplication Global App Data Component DataMonitoring ager ModularorganizationApplicationCode 2012 SL Corporation. All Rights Reserved.20 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelApplication Classpublic class MyApplication {// Global Application data // Component data public MyApplication (){// Create a JMX Agent to manage this AppSampleJmxAgent agent new SampleJmxAgent(this);}{ 2012 SL Corporation. All Rights Reserved.21 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelSample JMX Agent Classimport javax.management.*;import java.lang.management.*;public class SampleJmxAgent {public SampleJmxAgent (MyApplication myApp){// Get the platform MBeanServerMBeanServer mBeanServer ManagementFactory.getPlatformMBeanServer();// Create App Manager instanceSampleAppManager managerBean new SampleAppManager(mBeanServer, myApp);// Multiple Component Manager instances .} 2012 SL Corporation. All Rights Reserved.22 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelSample App Manager Classpublic class SampleAppManager implements SampleAppManagerMBean{private MyApplication myApp;public SampleAppManager (MBeanServer mBeanServer, MyApplication myApp){// Save reference to Appthis.myApp myApp;// Uniquely identify this MBean instance and register with the MBeanServertry {ObjectName managerName new ObjectName("MyApplication:name AppManager");mBeanServer.registerMBean(this, managerName);} catch(Exception e) {e.printStackTrace();}}// data access method definitions } 2012 SL Corporation. All Rights Reserved.23 2012 SL Corporation. All Rights Reserved.

1) Abstract Monitoring ModelSample App Manager MBean Classpublic interface SampleAppManagerMBean{// data access method declarations } 2012 SL Corporation. All Rights Reserved.24 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelMake monitoring data easy to consume !Avoid complex data structures that must beparsedMake data “self-contained” – include indexes 2012 SL Corporation. All Rights Reserved.25 2012 SL Corporation. All Rights Reserved.

2) Simple Data Model7 Basic Data Types:int, longdouble, floatbooleanStringDate 2012 SL Corporation. All Rights Reserved.26 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelApplication Classpublic class MyApplication {// Global Application variablesint intVar 123;long longVar 12345678900L;float floatVar 12.34f;double doubleVar 567.899999;boolean booleanVar true;String stringVar "TestString";java.util.Date dateVar new java.util.Date();public MyApplication (){// Create a JMX Agent to manage this Appagent new SampleJmxAgent(this);}{ 2012 SL Corporation. All Rights Reserved.27 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelSample App Manager Classpublic class SampleAppManager implements SampleAppManagerMBean{// data access method definitions public int getIntVar () { return myApp.intVar; }public void setIntVar (int i) { }public long getLongVar () { return myApp.longVar; }public void setLongVar (long l) { }public float getFloatVar () { return myApp.floatVar; }public void setFloatVar (float f) { }public double getDoubleVar () { return myApp.doubleVar; }public void setDoubleVar (double d) { }public boolean getBooleanVar () { return myApp.booleanVar; }public void setBooleanVar (boolean b) { }public String getStringVar () { return myApp.stringVar; }public void setStringVar (String s) { }public java.util.Date getDateVar () { return myApp.dateVar; }public void setDateVar (java.util.Date date) { }} 2012 SL Corporation. All Rights Reserved.28 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelSample App Manager MBean Classpublic interface SampleAppManagerMBean{// data access method declarations public int getIntVar ();public void setIntVar (int i);public long getLongVar ();public void setLongVar (long l);public float getFloatVar ();public void setFloatVar (float f);public double getDoubleVar ();public void setDoubleVar (double d);public boolean getBooleanVar ();public void setBooleanVar (boolean b);public String getStringVar ();public void setStringVar (String s);public java.util.Date getDateVar ();public void setDateVar (java.util.Date date);} 2012 SL Corporation. All Rights Reserved.29 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelViewed in jconsole 2012 SL Corporation. All Rights Reserved.30 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelViewed in RTView Builder One tabular row per MBean, permitting aggregation across multiple instances 2012 SL Corporation. All Rights Reserved.31 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelOther Useful Data Types:Should be used with care (supported byRTView, but not all JMX tools)ArrayCompositeDataTabularData 2012 SL Corporation. All Rights Reserved.32 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelArrayRTView and jconsole can view all array elements at once In MyApplication:String[] serverList { "bogart", "bacall", "jones", "clarion" };In AppManager:public String[] getServerList () { return myApp.serverList; }In AppManagerMBean:public String[] getServerList () ; 2012 SL Corporation. All Rights Reserved.33 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelCompositeDataSingle row data structure, consisting of multiple typed fields (items)CompositeType ctype new CompositeType(typeName, indexNames, itemNames, itemNames, itemTypes);Not recommended for general use Many developers use Composite, but difficult to use by clientsRTView can see them easily, but jconsole can only view one element at a time(as well as most other JMX tools) 2012 SL Corporation. All Rights Reserved.34 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelTabularDataTabular data structure, consisting of multiple Composite rowsCompositeType ctype new CompositeType(“typeName”, “description”, itemNames, itemDescriptions, itemTypes);TabularType ttype new TabularType(“typeName”, ”description”, ctype, indexNames)Recommended for use when performance is an issue More work to use by clients, but is most efficient for large tablesAlternative to multiple instances of single MBeanRTView can see them easily, but jconsole can only view one element at a time(as well as most other JMX tools) 2012 SL Corporation. All Rights Reserved.35 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelTabularDataSample use case:Oracle Coherence distributed cache systeme.g. 100 Nodes x 50 caches distributed 5000 MBeansSL provided optimized TabularData version of same data:100 TabularData MBeans with 50 rows eachUsed 3 X less network bandwidth to transfer and 10 X speed improvement 2012 SL Corporation. All Rights Reserved.36 2012 SL Corporation. All Rights Reserved.

2) Simple Data ModelTabularDataRTView displayshowing data fromthousands ofMbeans inheatmap 2012 SL Corporation. All Rights Reserved.37 2012 SL Corporation. All Rights Reserved.

3) Pluggable Transport MechanismSeparate monitoring data structures fromtransport codeIn-memory monitoring data stored in uniformfashion input to transport mechanism 2012 SL Corporation. All Rights Reserved.38 2012 SL Corporation. All Rights Reserved.

3) Pluggable Transport MechanismThe JMX Data Model, e.g. SimpleType andTabularType importantTransport can be anything 2012 SL Corporation. All Rights Reserved.39 2012 SL Corporation. All Rights Reserved.

3) Pluggable Transport MechanismThe JMX Data Model, e.g. SimpleType andTabularType importantTransport can be anything:Log FileDatabase TableJMS Message 2012 SL Corporation. All Rights Reserved.40 2012 SL Corporation. All Rights Reserved.

3) Pluggable Transport MechanismArchitecture ViewProvide Transport Plugins / InterfacesMonitoring agerApplicationCode MBeanInterfaceJMX APISQLInterfaceDatabase TableJMSInterfaceJMS MessageOtherInterfaceOther TransportMany differentinterfaces could beprovided 2012 SL Corporation. All Rights Reserved.41 2012 SL Corporation. All Rights Reserved.

4) Some things NOT to do Forget to include index columns in your dataEncode monitoring data in XML string fieldsUse overly complex keysInconsistent key, index column mappings 2012 SL Corporation. All Rights Reserved.42 2012 SL Corporation. All Rights Reserved.

4) Some things NOT to do Additional Info in JDJ Technical Paper: 2012 SL Corporation. All Rights Reserved.43 2012 SL Corporation. All Rights Reserved.

Resources:www.sl.com 2012 SL Corporation. All Rights Reserved.44 2012 SL Corporation. All Rights Reserved.

Q&A 2012 SL Corporation. All Rights Reserved.45 2012 SL Corporation. All Rights Reserved.

Collects, Analyzes, and Visualizes data from different sources, many using JMX RTView Enterprise Monitor RTView Classic Generic JVM Apache/ Tomcat VMware Amazon EC2 IBM WebSphere Oracle WebLogic Business Events Active Spaces Oracle Coherence and many more RTView “IDE” TIBCO EM