Jvm mbeans jmxtran

Post on 15-Jan-2015

1.855 views 2 download

Tags:

description

Presentation

Transcript of Jvm mbeans jmxtran

www.exoplatform.com

Copyright 2011 eXo Platform

Introduced by: Nghi Nguyen Van~ March, 22nd 2012 ~

JVM Inside & monitoring with MBean, jmxtrans, graphite

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

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

www.exoplatform.com

Copyright 2011 eXo Platform

Purposes of monitoring JVM

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)

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

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

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

9www.exoplatform.com

Copyright 2011 eXo Platform

●●●●• We cant know until we measure it

Why measure – cont.

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.

www.exoplatform.com

Copyright 2011 eXo Platform

JVM & Memory Structure in JVM

12www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Java – how java code executed

13www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Java Virtual Machine architecture

14www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Java - JVM Memory Structure – Heap detail

www.exoplatform.com

Copyright 2011 eXo Platform

JMX and MBean

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

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

18www.exoplatform.com

Copyright 2011 eXo Platform

●●●●The JMX architecture

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

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

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

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

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

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

25www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Tools that allow to connect to JVM remotely via JMX

• Jconsole• visualvm• Memory Analyzer Tool• …

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• …

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

www.exoplatform.com

Copyright 2011 eXo Platform

Jmxtrans as a JVM query tool

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...

30www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Jmxtrans introduction (cont.)

31www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Jmxtrans introduction (cont.)

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

33www.exoplatform.com

Copyright 2011 eXo Platform

●●●●eXo Platform MBean items (cont.)

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

35www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Jmxtrans query – single query – MBean query part

36www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Jmxtrans query – single query – Output part

37www.exoplatform.com

Copyright 2011 eXo Platform

●●●●Jmxtrans query – single query – list of query

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

www.exoplatform.com

Copyright 2011 eXo Platform

Demo graphite as a JVM historical data manager tool

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

41www.exoplatform.com

Copyright 2011 eXo Platform

●●●●eXo Platform JVM historical data

42www.exoplatform.com

Copyright 2011 eXo Platform

●●●●eXo Platform JVM historical data (cont.)

43www.exoplatform.com

Copyright 2011 eXo Platform

●●●●eXo Platform JVM historical data (cont.)

44www.exoplatform.com

Copyright 2011 eXo Platform

●●●●eXo Platform JVM historical data (cont.)

45www.exoplatform.com

Copyright 2011 eXo Platform

●●●●eXo Platform JVM historical data (cont.)

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

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

www.exoplatform.com

Copyright 2011 eXo Platform

Q & A

www.exoplatform.com

Copyright 2011 eXo Platform

Thank you!