Sun Identity Manager 8.1 System Administrator's Guide

Using DTrace

The DTrace facility is a dynamic tracing framework for the Solaris 10 operating system that enables you to monitor JVM activity.

DTrace contains more than 30,000 probes and uses integrated user-level and kernel-level tracing to give you a view into your production system. You can also trace arbitrary data and expressions by using the D language, which is similar to C or awk. The DTrace facility also includes special support for monitoring the JVM, and enables you to watch your whole system and span outside the JVM.

DTrace is easiest to use with Java 6 because probes are built into the JVM. The facility also works with Java 1.4 and Java 5, but you must download JVM PI or JVM TI agents from the following URL:

https://solaris10-dtrace-vm-agents.dev.java.net/

The following example shows how to write a DTrace script.


Example 4–2 Example DTrace Script


#!/usr/sbin/dtrace -Zs 
#pragma D option quiet
hotspot$1::: 
{
  printf("%s\n", probename); 
}

In this example, you would replace $1 with the first argument to the script, which is the PID of the Java process you want to monitor. For example:

# ./all-jvm-probes.d 1234

The following table describes the commands you can use to enable different DTrace probes.

Table 4–3 DTrace Commands

Command 

Description 

-XX:+DTraceMonitorProbes

Enables JVM support in Java 6 (patches for Java 1.4 and Java 5) 

-XX:+ExtendedDTraceProbes

Provides the following information: 

  • JVM startup (begin and end) and shutdown

  • Thread starting and stopping

  • Class loading and unloading

  • Garbage collection (several options available)

  • JIT compilation begin and end

  • Compiled method loading and unloading

  • Monitor contention, wait, and notify

  • Method entry, method return, and object allocation

/usr/sbin/dtrace -n ’hotspot*:::’

Enables all JVM probes for all Java processes on the system 

/usr/sbin/dtrace -n ’hotspot1234:::’

Enables all JVM probes for only the Java process with PID 1234

/usr/sbin/dtrace -n ’hotspot1234:::gc-begin’

Enables only the probe that starts when garbage collection for process 1234 begins


Note –

Because DTrace causes additional work in the system, enabling this facility affects system performance. The effect is often negligible, but can become substantial if you enable many probes with costly enablings.

Instructions for minimizing the performance effect of DTrace are provided in the “Performance Considerations” chapter of the Solaris Dynamic Tracing Guide.

For more information about DTrace, see /usr/demo/dtrace and man dtrace.