Google

Jun 17, 2014

How do you monitor the JVM?

Since Java SE 5.0, the JRE provides a mean to manage and monitor the Java Virtual Machine. It comes in two flavors:



The JVM has built-in instrumentation that enables you to monitor and manage it using Java Management eXtension (JMX). You can also monitor instrumented applications with JMX. To start a Java application with the management agent for local monitoring, set the following JVM argument when you run your application.

$JAVA_HOME/bin/java -Dcom.sun.management.jmxremote  MyApp
 
To start the JConsole:

$JAVA_HOME/bin/jconsole

The other is a Simple Network Management Protocol (SNMP) agent that builds upon the management and monitoring API of the Java SE platform, and exposes the same information through SNMP.

Proactive application monitoring is vital to detect and respond to problems - before an end user is even aware that a problem exists, especially for revenue-generating production environments. it's also important to be able to gather metrics about performance and resource consumption, especially for long-running applications like websites. While you can get some information from the operating system (such as CPU and memory usage), you will often need much more detailed information.




Problem
Symptom
Tool
Insufficient memory
Java.lang.OutOfMemoryError indicating out of heap space, perm gen space or native swap memory space.

jhat
Memory leaks
Frequent garbage collection and growing use of memory indicated by saw tooth shaped graph. This can cause the application to slow down.
jconsole, jstat, jmap, JAMon, VisualVM, and commercial tools such as Wily's Introscope or YourKit Java Profiler.

Deadlocked threads waiting for each other, endlessly looping threads, and racing threads ending up waiting for other long running thread to release the monitor (known as thread contention).
Threads blocked on object monitors or java.util.concurrent locks. Deadlocked threads can cause a part or the whole application to become unresponsive.

Looping threads can cause the application to hang.

Thread contention issues can adversely affect performance and scalability.
jconsole, jstack, and jmap, VisualVM, and commercial tools such as Wily's Introscope or YourKit Java Profiler.
JVM abruptly going down and other network fault monitoring.
Causing an application or service to be down.
tools such as Wily's Introscope, capable of monitoring the JVM environment and emitting SNMP traps to an IBM's Tivoli console to raise alarms.

network switches and routers, with built-in SNMP capabilities to send traps when network faults occur.


Many organizations use commercial tools like Wily's Introscope, Tivoli Monitoring, HP SiteMonitor, etc and SNMP trap handling tools like Nagios to provide quality of service (QoS) on their mission critical applications.

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home