jvm mbeans jmxtran
DESCRIPTION
PresentationTRANSCRIPT
![Page 1: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/1.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Introduced by: Nghi Nguyen Van~ March, 22nd 2012 ~
JVM Inside & monitoring with MBean, jmxtrans, graphite
![Page 2: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/2.jpg)
2www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Agenda
1. Introduction2. JVM & Memory Structure in JVM3. JMX and MBean4. Jmxtrans as a JVM query tool5. Demo graphite as a JVM historical data manager tool6. Tips and tricks7. Q & A
![Page 3: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/3.jpg)
3www.exoplatform.com
Copyright 2011 eXo Platform
●●●●
Purpose of this presentation:Purposes of monitoring a JVM
Introduce about a way to monitor a JVM
Introduce about how to build an eXo product JVM monitoring system
This presentation serves to:● Leaders to understand about performance test reports and to give
advices & suggestions with performance test reports base on the JVM detail information
● Who is new in using JVM monitoring tools
● Testers who have to work directly and often with JVM monitoring tools
Introduction
![Page 4: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/4.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Purposes of monitoring JVM
![Page 5: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/5.jpg)
5www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Value of a software product
• Meet the business requirement• Users satisfaction• Save time and money, give more business value• Rich features• Stable, high performance• Easy to backup/maintain/improve• …
Value of code (Value of a product)
![Page 6: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/6.jpg)
6www.exoplatform.com
Copyright 2011 eXo Platform
●●●●• The code generates value when it is used/run/inherit not when we
write it• We need to know how our code performed when it run• We cannot do this unless we measure it
We want to make our code more value
![Page 7: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/7.jpg)
7www.exoplatform.com
Copyright 2011 eXo Platform
●●●●
• map ≠ territory• map of Ha noi ≠ city of Ha noi• the way we talk ≠ the way it is• the way we think of ≠ the way itself• perception ≠ reality
Why measure
![Page 8: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/8.jpg)
8www.exoplatform.com
Copyright 2011 eXo Platform
●●●●• We have mental model of the code• mental model, it's not the code• Sometime, it's wrong• Sometime, it’s a big mistake
Why measure – mental model, it's not the code
![Page 9: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/9.jpg)
9www.exoplatform.com
Copyright 2011 eXo Platform
●●●●• We cant know until we measure it
Why measure – cont.
![Page 10: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/10.jpg)
10www.exoplatform.com
Copyright 2011 eXo Platform
●●●●• This affect how we make decisions
1. A better mental model make us better at deciding what to do
2. A better mental model make us better at generating value
3. Measuring make our decisions better
Why measure – cont.
![Page 11: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/11.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
JVM & Memory Structure in JVM
![Page 12: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/12.jpg)
12www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Java – how java code executed
![Page 13: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/13.jpg)
13www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Java Virtual Machine architecture
![Page 14: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/14.jpg)
14www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Java - JVM Memory Structure – Heap detail
![Page 15: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/15.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
JMX and MBean
![Page 16: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/16.jpg)
16www.exoplatform.com
Copyright 2011 eXo Platform
●●●●• Java Management Extension
• It consists of:
• An architecture• Design patterns• Java APIs• Services for application and network management
What is the JMX
![Page 17: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/17.jpg)
17www.exoplatform.com
Copyright 2011 eXo Platform
●●●●What is the JMX (cont.)
• Enables Java applications to be managed without heavy investment– Little impact on Java application design
• Provides scaleable management architecture– Component architecture, pick and choose components
• Integrates existing management solutions– Can be managed via multiple protocols, e.g. SNMP, WBEM, HTTP
– Information model independent
• Leverages existing standard Java
![Page 18: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/18.jpg)
18www.exoplatform.com
Copyright 2011 eXo Platform
●●●●The JMX architecture
![Page 19: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/19.jpg)
19www.exoplatform.com
Copyright 2011 eXo Platform
●●●●The JMX architecture (cont.)
• The JMX architecture defines three levels:– Instrumentation Level
• How to instrument managed resources– Server Level
• How managed resources are managed via the management server– Distributed Services Level
• How distributed clients and management applications access and interact with servers and the managed resources in the servers
![Page 20: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/20.jpg)
20www.exoplatform.com
Copyright 2011 eXo Platform
●●●●The JMX architecture (cont.)
• Basic goal– In a running Java application, we would like to be able to:
• Manage existing Java objects:– get an attribute value
– change an attribute value
– invoke an operation
• Add new Java objects:– using existing Java classes
– using new classes from an arbitrary location
• And do all this from a remote location
![Page 21: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/21.jpg)
21www.exoplatform.com
Copyright 2011 eXo Platform
●●●●MBean
• MBean: Managed bean. Java class implementing a management interface and representing a resource to be managed or monitored
• MBean– Defines how resources are instrumented using MBean– MBean instrumentation allows the resource to be manageable
through JMX-compliant agents• Notification Model
– MBean and other JMX components
may emit notifications• MBean Metadata Classes
– Describes the MBean's management
interface for management agents
and management
![Page 22: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/22.jpg)
22www.exoplatform.com
Copyright 2011 eXo Platform
●●●●MBean (cont.)
• An MBean exposes the management interface of the managed resource/object– The management interface is the set of information and controls that
a management application uses to operate on the resource
![Page 23: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/23.jpg)
23www.exoplatform.com
Copyright 2011 eXo Platform
●●●●MBean (cont.)
• An MBean exposes the management interface as:– Attributes which may be accessed
– Operations which may be invoked
– Notifications which may be emitted (optional)
– Constructors for the MBean's Java class
• An MBean follows design patterns– The way an attribute or operation to be exposed has to be declared
• An MBean must be registered in the MBean server to be visible remotely
• An MBean does not know about its MBean
![Page 24: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/24.jpg)
24www.exoplatform.com
Copyright 2011 eXo Platform
●●●●MBean (cont.)
• The MBean server is a registry of objects which are exposed to management operations in a server– Only registered MBean can be managed from outside the server's
JVM
• The MBean server only exposes an MBean's management interface (not the MBean's direct reference)
• Also provides standardized interface for accessing MBean within the same JVM
![Page 25: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/25.jpg)
25www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Tools that allow to connect to JVM remotely via JMX
• Jconsole• visualvm• Memory Analyzer Tool• …
![Page 26: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/26.jpg)
26www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Tools that allow to deal with MBean through web interface
• JBoss jmx console– Enable user name and password here: server/default/conf/props/jmx-
console-users.properties
• javamelody• …
![Page 27: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/27.jpg)
27www.exoplatform.com
Copyright 2011 eXo Platform
●●●●JMX notice – enable JMX RMI connection first
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=8004 -Dcom.sun.management.jmxremote.authenticate=false
![Page 28: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/28.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Jmxtrans as a JVM query tool
![Page 29: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/29.jpg)
29www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans introduction
• jmxtrans is a tool which allows you to connect to any number of Java Virtual Machines (JVM's) and query them for their attributes without writing a single line of Java code
• The attributes are exported from the JVM via Java Management Extensions (JMX)
• eXo Platform and others implement MBean interface
• The query language: JSON format.• OutputWriters:
– write output automatically base on class name
– can output to: graphite, gangila, keyout, RRD...
![Page 30: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/30.jpg)
30www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans introduction (cont.)
![Page 31: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/31.jpg)
31www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans introduction (cont.)
![Page 32: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/32.jpg)
32www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform MBean items
• eXo JCR session– exo:portal="portal",repository="repository",service=SessionRegistry
• Size• TimeOut
• eXo Cache: collaboration– exo:portal="portal",repository="repository",workspace="collaboratio
n",cache-type=JCR_CACHE,jmx-resource=CacheMgmtInterceptor
• Size• MissCount• HitCount• Capacity• TimeToLive
![Page 33: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/33.jpg)
33www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform MBean items (cont.)
![Page 34: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/34.jpg)
34www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans query – single query
• TARGET_JMX_PORT = eXo product JMX port• TARGET_JMX_HOST = eXo product host address• TARGET_GRAPHITE_HOST = graphite server address• TARGET_GRAPHITE_PORT = graphite server port• outputWriters class:
com.googlecode.jmxtrans.model.output.GraphiteWriter
![Page 35: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/35.jpg)
35www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans query – single query – MBean query part
![Page 36: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/36.jpg)
36www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans query – single query – Output part
![Page 37: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/37.jpg)
37www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans query – single query – list of query
![Page 38: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/38.jpg)
38www.exoplatform.com
Copyright 2011 eXo Platform
●●●●Jmxtrans query – wildcard syntax
• Jmxtrans support wildcard syntax• typeNames should be defined wildcard applied
– Purpose is: filtering and classifying
![Page 39: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/39.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Demo graphite as a JVM historical data manager tool
![Page 40: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/40.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Install & using graphite Install graphite Build graphite dashboards Data calculation while building graphs get single image by URL Export graph data to csv data format
![Page 41: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/41.jpg)
41www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform JVM historical data
![Page 42: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/42.jpg)
42www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform JVM historical data (cont.)
![Page 43: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/43.jpg)
43www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform JVM historical data (cont.)
![Page 44: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/44.jpg)
44www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform JVM historical data (cont.)
![Page 45: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/45.jpg)
45www.exoplatform.com
Copyright 2011 eXo Platform
●●●●eXo Platform JVM historical data (cont.)
![Page 46: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/46.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Tips & tricks
1. Perform jmxtrans.sh start many time until the messgae that there is a jmxtrans process exist
2. jmxtrans must start after the application start3. use curl, wget… to collect specific data/graph from
graphite automatically4. use the graphs’ csv datasheet to compare data between
graphs’ content5. A graph with multiple data lines can hide some
information from some line. Try to expand into multiple graphs
6. try to export all the data in a needed term to use later7. Default graphite data history is 24hours, it should be
changed to longer to avoid missing of needed data
![Page 47: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/47.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Links
1. http://code.google.com/p/jmxtrans2. http://graphite.wikidot.com/3. https://wiki-int.exoplatform.org/display/QAF/Graphite4. http://www.oracle.com/technetwork/java/javase/tech/
docs-jsp-135989.html5. http://
docs.oracle.com/javase/tutorial/jmx/MBean/index.html
6. http://docs.oracle.com/javase/specs/jls/se5.0/html/j3TOC.html
![Page 48: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/48.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Q & A
![Page 49: Jvm mbeans jmxtran](https://reader035.vdocuments.site/reader035/viewer/2022081414/54b6a5f84a7959b5588b47c4/html5/thumbnails/49.jpg)
www.exoplatform.com
Copyright 2011 eXo Platform
Thank you!