Observability Using Java 2 Platform, Standard Edition 5.0, and the Solaris OSA. Sundararajan and Jim Holmlund, May 2006 Java 2 Platform, Standard Edition 5.0 (J2SE 5.0), is the latest FCS release available for download from Java.sun.com. The J2SE 5.0 platform comes with a number of observability tools, especially on the Solaris 10 Operating System. Support for Java Technology Using DTrace
The Solaris 10 OS introduced Dynamic Tracing (DTrace). From J2SE 5.0 update 1 onwards, a new DTrace action called
#!/usr/sbin/dtrace -s
syscall::pollsys:entry
/ pid == $1 / {
/* print at most 50 frames */
jstack(50);
}
Here is the output of running the above script against a Java process: libc.so.1`__pollsys+0xa libc.so.1`poll+0x52 libjvm.so`int os_sleep(long long,int)+0xb4 libjvm.so`int os::sleep(Thread*,long long,int)+0x1ce libjvm.so`JVM_Sleep+0x1bc java/lang/Thread.sleep dtest.method3 dtest.method2 dtest.method1 dtest.main [... more output deleted for brevity ...]
The Using DTrace Agent for Java Virtual MachinesOne DTrace agent library is called the "dvmti" agent. This can be run inside the Java Virtual Machine (JVM) to provide DTrace probes that are specific to the JVM and the Java platform. This agent is available for download from the Java.net project solaris10-dtrace-vm-agents. The dvmti agent uses the Java Virtual Machine Tool Interface (JVM TI). Specifically, the agent library utilizes the JVM TI interface to request various VM events and provide DTrace probes in the callback code for those events. To use these DTrace probes for the JVM and Java code, the Java application has to be started as shown here: java -Xrundvmti[:options] <MainClass> Where options are: all same as: unloads,allocs,stats,methods help print help message unloads track class unloads allocs track object allocations and frees stats generate heap stats after each GC methods generate method entry exit events exclude=name exclude class names default is none of unloads, allocs, stats, or methods.
The dvmti agent will utilize byte code instrumentation (BCI) where needed and will need a jar file called export JAVA_TOOL_OPTIONS="-Xrundvmti:all" Effect of Using DTrace on Java Programs
DTrace is designed as a production-mode observability system offering "zero impact when not used". When probes are not enabled, the observed system is not affected. The Observability Tools in the J2SE 5.0 PlatformIn addition to the integration of DTrace with Java technology, J2SE 5.0 software contains many other observability tools. A summary of these tools follows, with links to references that offer more details. JConsole
JConsole uses the extensive Java Management Extension (JMX) instrumentation of the JVM to provide information about performance and resource consumption of applications running on the Java platform. (For more information, see the article Using JConsole to Monitor Applications.) In J2SE 5.0 technology, the application to be monitored has to be started with the Use in Production Systems JConsole starts a JMX agent inside the JVM of the observed Java program. A non-zero impact results from the running of an additional agent -- but the impact is minimal. Also, despite the fact that JConsole is useful in monitoring local applications for development and prototyping, this is not recommended for production environments. The reason is that JConsole itself consumes significant system resources. Remote monitoring is recommended to isolate the JConsole application from the platform being monitored. So, for production systems, it is better to use JConsole in remote mode. Security options are available for secure remote monitoring.
Unlike
Use in Production Systems
Tools for Postmortem Observability in the J2SE 5.0 Platform
J2SE 5.0 software supports postmortem observability tools that obtain information from hung Java processes or Java core dumps. These tools use the Solaris libproc library to attach and read from the observed program. During the period of observation, the target program is suspended. These tools are expected to be used when Java processes are hung or when you have a core dump from a Java process. Whenever possible, consider using
For information on
Starting from J2SE 5.0 update release 1.5.0_05, a new
ReferencesBlogs on Solaris and Java Platform Observability Articles and Guides
Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License. |
|