Manage and Monitor your JVM with JMX



Similar documents
TDA - Thread Dump Analyzer

Tools in the Box. Quick overview on helpful tools in the JDK and use cases for them. Florin Bunau

CS5233 Components Models and Engineering

Java Troubleshooting and Performance

How to Enable Remote JMX Access to Quartz Schedulers. M a y 1 2,

Deployment and Monitoring. Pascal Robert MacTI

Java Debugging Ľuboš Koščo

Java Mission Control

Moving beyond hardware

Configuring and Integrating JMX

Enterprise Application Management with Spring

VisualVM: Integrated and Extensible Troubleshooting Tool for the Java Platform

Using jvmstat and visualgc to Solve Memory Management Problems

Java Monitoring. Stuff You Can Get For Free (And Stuff You Can t) Paul Jasek Sales Engineer

OSGi Service Platform in Integrated Management Environments Telefonica I+D, DIT-UPM, Telvent. copyright 2004 by OSGi Alliance All rights reserved.

Performance Monitoring and Tuning. Liferay Chicago User Group (LCHIUG) James Lefeu 29AUG2013

All The Leaves Aren t Brown

Deploying a Logi Info Application on WAS

THE BUSY DEVELOPER'S GUIDE TO JVM TROUBLESHOOTING

Effective Java Programming. measurement as the basis

A technical guide for monitoring Adobe LiveCycle ES deployments

Monitoring and Managing a JVM

Robert Honeyman

How To Improve Performance On An Asa 9.4 Web Application Server (For Advanced Users)

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Configuration Guide - OneDesk to SalesForce Connector

Introduction to Sun ONE Application Server 7

Oracle WebLogic Server

Production time profiling On-Demand with Java Flight Recorder

Advanced Liferay Architecture: Clustering and High Availability

1. Introduction 2. Using Java Management Extension (JMX) 3. Remote Monitoring

Oracle WebLogic Server 11g Administration

Profiling Java Applications. Kostis Kapelonis - Agilis SA

Meeting #47. JMX Java Management Extensions. Dominik Dorn Dominik Dorn - JMX

High-Availability. Configurations for Liferay Portal. James Min. Senior Consultant / Sales Engineer, Liferay, Inc.

1 How to Monitor Performance

Monitoring Apache Tomcat and the Apache Web Server. Rainer Jung

Monitoring Tomcat with JMX

HP OO 10.X - SiteScope Monitoring Templates

WEBAPP PATTERN FOR APACHE TOMCAT - USER GUIDE

ADAM 5.5. System Requirements

Insight into Performance Testing J2EE Applications Sep 2008

Network Communication

Exception Handling In Web Development DevelopIntelligence LLC

J2EE-JAVA SYSTEM MONITORING (Wily introscope)

Consuming and Producing Web Services with WST and JST. Christopher M. Judd. President/Consultant Judd Solutions, LLC

BS1000 command and backlog protocol

SCUOLA SUPERIORE SANT ANNA 2007/2008

WEBLOGIC ADMINISTRATION

Netbeans 6.0. José Maria Silveira Neto. Sun Campus Ambassador

Lecture 19: Web Based Management

Open Source Performance Testing

An Oracle White Paper Sep Embedding Oracle WebLogic Server

Monitoring HP OO 10. Overview. Available Tools. HP OO Community Guides

Open Message Queue. Developer's Guide for JMX Clients Release 5.0

An Overview of Java. overview-1

This training is targeted at System Administrators and developers wanting to understand more about administering a WebLogic instance.

Liferay Performance Tuning

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

Java Garbage Collection Basics

Module 13 Implementing Java EE Web Services with JAX-WS

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Monitoring Java Applications

WebSphere Server Administration Course

IBM WebSphere Server Administration

Simba XMLA Provider for Oracle OLAP 2.0. Linux Administration Guide. Simba Technologies Inc. April 23, 2013

.NET and J2EE Intro to Software Engineering

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

SNMP-1 Configuration Guide

Hello World RESTful web service tutorial

Practical Performance Understanding the Performance of Your Application

Monitor Your Key Performance Indicators using WSO2 Business Activity Monitor

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

WebLogic Server Administration

System i Windows Integration Solutions

THE BUSY JAVA DEVELOPER'S GUIDE TO WEBSPHERE DEBUGGING & TROUBLESHOOTING

Oracle JRockit Mission Control Overview

Installation and Configuration Guide for Windows and Linux

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

9/26/2013. Installer.ps1 will validate all settings before deployment. Define your deployment. Define your deployment Run PDT Downloader

WebLogic Server 11g Administration Handbook

Oracle WebLogic Server 10g R3: Monitoring and Performance Tuning

Realization of the High-density SaaS Infrastructure with a Fine-grained Multitenant Framework

Stock Trader System. Architecture Description

Oracle WebLogic Thread Pool Tuning

Eclipse Memory Analyzer and other Java stuff

Installation and Configuration Guide for Windows and Linux

talent. technology. true business value

Java CPD (I) Frans Coenen Department of Computer Science

Introduction to Parallel Programming and MapReduce

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

Advanced Java Client API

ELIXIR LOAD BALANCER 2

BAPI. Business Application Programming Interface. Compiled by Y R Nagesh 1

Chapter 1. JOnAS and JMX, registering and manipulating MBeans

Hacking (and securing) JBoss AS

A Scalability Model for Managing Distributed-organized Internet Services

Clustering with Tomcat. Introduction. O'Reilly Network: Clustering with Tomcat. by Shyam Kumar Doddavula 07/17/2002

OpenESB Standalone Edition V3.0 Web admin console

Java in Web 2.0. Alexis Roos Principal Field Technologist, CTO Office OEM SW Sales Sun Microsystems, Inc.

Transcription:

Manage and Monitor your JVM with JMX Christopher M. Judd

Christopher M. Judd CTO and Partner at leader Columbus Developer User Group (CIDUG)

JMX

JMX Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring applications, system objects, devices (e. g. printers) and service oriented networks. Those resources are represented by objects called s (for Managed Bean). In the API, classes can be dynamically loaded and instantiated. Managing and monitoring applications can be designed and developed using the Java Dynamic Management Kit. Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

jconsole

Visual VM jvisualvm http://visualvm.java.net/ visualvm

VisualVM s plug-in

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

package com.manifestcorp.webperf; import org.slf4j.logger; import org.slf4j.loggerfactory; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; @Controller public class IndexController { private static Logger log = LoggerFactory.getLogger(IndexController.class); } @RequestMapping(value = "/") public String index() { System.out.println("HERE!!!"); } log.info("still HERE!!!"); return "WEB-INF/jsps/index.jsp"; HERE!!!

logback.xml <configuration> <jmxconfigurator /> <appender name="stdout" class="ch.qos.logback.core.consoleappender"> <encoder> <pattern>%d{hh:mm:ss.sss} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="error"> <appender-ref ref="stdout" /> </root> </configuration>

package com.manifestcorp.webperf; import org.slf4j.logger; import org.slf4j.loggerfactory; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; @Controller public class IndexController { private static Logger log = LoggerFactory.getLogger(IndexController.class); } @RequestMapping(value = "/") public String index() { System.out.println("HERE!!!"); } log.info("still HERE!!!"); return "WEB-INF/jsps/index.jsp"; HERE!!! 23:53:03.556 [http-bio-8080-exec-8] INFO c.m.webperf.indexcontroller - STILL HERE!!!

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

public interface IndexCounter { int getcount(); void reset(); }

public class IndexCounter implements IndexCounter { static Logger log = LoggerFactory.getLogger(IndexCounter.class); private AtomicInteger count = new AtomicInteger(); private static IndexCounter instance; static { } try { Server mbs = ManagementFactory.getPlatformServer(); ObjectName name = new ObjectName("com.manifestcorp:type=IndexCounter"); instance = new IndexCounter(); mbs.register(instance, name); } catch(exception ex) { } log.error("unable to register IndexCounter ", ex); private IndexCounter() {} public int getcount() { return count.get(); } public void increment() { count.incrementandget(); } public void reset() { count.set(0); } public static IndexCounter getinstance() { return instance; } }

package com.manifestcorp.webperf; public interface IndexCounter { } int getcount(); void reset();

package com.manifestcorp.webperf; public interface IndexCounter { } int getcount(); void reset();

@Component @ManagedResource(objectName="com.manifestcorp:type=AlternateCounter") public class AlternateCounter { static Logger log = LoggerFactory.getLogger(AlternateCounter.class); private AtomicInteger count = new AtomicInteger(); @ManagedAttribute public int getcount() { return count.get(); } public void increment() { count.incrementandget(); } @ManagedOperation public void reset() { count.set(0); } }

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation=" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd <context:component-scan base-package="com.manifestcorp" /> <mvc:annotation-driven /> <bean id="exporter" class="org.springframework.jmx.export.exporter"> <property name="assembler" ref="assembler"/> <property name="namingstrategy" ref="namingstrategy"/> <property name="autodetect" value="true"/> </bean> <bean id="jmxattributesource" class="org.springframework.jmx.export.annotation.annotationjmxattributesource"/> <!-- will create management interface using annotation metadata --> <bean id="assembler" class="org.springframework.jmx.export.assembler.metadatainfoassembler"> <property name="attributesource" ref="jmxattributesource"/> </bean> <!-- will pick up the ObjectName from the annotation --> <bean id="namingstrategy" class="org.springframework.jmx.export.naming.metadatanamingstrategy"> <property name="attributesource" ref="jmxattributesource"/> </bean> </beans>

@Component @ManagedResource(objectName="com.manifestcorp:type=AlternateCounter") public class AlternateCounter { } static Logger log = LoggerFactory.getLogger(AlternateCounter.class); private AtomicInteger count = new AtomicInteger(); @ManagedAttribute public int getcount() { return count.get(); } public void increment() { count.incrementandget(); } @ManagedOperation public void reset() { count.set(0); }

@Component @ManagedResource(objectName="com.manifestcorp:type=AlternateCounter") public class AlternateCounter { } static Logger log = LoggerFactory.getLogger(AlternateCounter.class); private AtomicInteger count = new AtomicInteger(); @ManagedAttribute public int getcount() { return count.get(); } public void increment() { count.incrementandget(); } @ManagedOperation public void reset() { count.set(0); }

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

import javax.management.remote.* println "Starting..." def serverlist = args.length > 0? args : ['appserv.guest', '192.168.248.129'] serverlist.each { servername -> } try { println "\nserver: $servername" def url = "service:jmx:rmi:///jndi/rmi://$servername:6969/jmxrmi" def connection = JMXConnectorFactory.connect(new JMXServiceURL(url)) def server = connection.serverconnection def mbean = new Groovy(server, 'java.lang:type=memory') println String.format('%15s %7.2f/%7.2f (used/max)', 'heap', } catch (e) { println e } println "Done..." def inbytes(amount) { } return amount/1000000 Starting... inbytes(mbean.heapmemoryusage.used), inbytes(mbean.heapmemoryusage.max)) Server: appserv.guest heap 19.74/ 438.11 (used/max) Server: 192.168.248.129 heap 20.09/ 438.11 (used/max) Done...

Remote Access

Remote Access monitoring tools JMX bean 1 JMX bean 2 server jvisualvm jconsole JVM jstad jps jinfo jmap jstack jvisualvm jconsole JVM

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6969 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6969 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password \ -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access \ jmxremote.password monitorrole QED controlrole R&D (this file must be read-only for the user running app) jmxremote.access monitorrole readonly controlrole readwrite example files can be found at <java_home>/jre/lib/management

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

http://www.hyperic.com/ http://www.opennms.org/ http://www.nagios.org/

Manager Level RMI HTTP HTTP SNMP Connector Connector Adaptor Adaptor Agent Level Server (JVM) (app server) (library) (custom) Instrumentation Level Java Virtual Machine

SNMP

1.3.6.1.4.1.42.2.145.3.163.1.1.2.11 rather than java.lang:type=memory HeapMemoryUsage

Make your own tools

Starting... Date: Mon Apr 23 09:46:23 EDT 2012 Server: 10.0.50.161 cpu usage 65.12% heap 1665.33/2138.77 (used/max) threads 207/198/218 (live/daemon/peak) queue size 0 [mls_mail] 0/ 10/ 60 (busy/total/max) 2rw7tt8m1miverrzbuxaz 7f5c693a [sessionlog] 0/ 20/100 (busy/total/max) 2rw7tt8m1miverrzbuxaz 3612afd8 [mls] 5/ 35/300 (busy/total/max) 2rw7tt8m1miverrzbuxaz 6a48ffbc active sessions 906 Server: 10.0.50.162 cpu usage 1.40% heap 850.19/2138.77 (used/max) threads 210/201/213 (live/daemon/peak) queue size 0 [mls] 0/ 25/300 (busy/total/max) 2rw7tu8m1m49xyl3vtggq 60f00e0f [mls_mail] 0/ 10/ 60 (busy/total/max) 2rw7tu8m1m49xyl3vtggq 5999ef99 [sessionlog] 0/ 15/100 (busy/total/max) 2rw7tu8m1m49xyl3vtggq 15a1ad24 active sessions 321 Server: 10.0.50.164 cpu usage 95.79% heap 1194.39/2138.77 (used/max) threads 431/421/1308 (live/daemon/peak) queue size 38 [sessionlog] 5/ 85/100 (busy/total/max) 2rw7tw8m1mj7yhpaojbdy 1bdf2b92 [mls] 60/300/300 (busy/total/max) 2rw7tw8m1mj7yhpaojbdy 334021a9 [mls_mail] 13/ 60/ 60 (busy/total/max) 2rw7tw8m1mj7yhpaojbdy 4da84fae active sessions 664 Done...

Christopher M. Judd CTO and Partner email: cjudd@juddsolutions.com web: www.juddsolutions.com blog: juddsolutions.blogspot.com twitter: javajudd