1*e137d3e0Schristos #!/usr/sbin/dtrace -Zs
2*e137d3e0Schristos /*
3*e137d3e0Schristos  * j_events.d - count Java events using DTrace.
4*e137d3e0Schristos  *              Written for the Java hotspot DTrace provider.
5*e137d3e0Schristos  *
6*e137d3e0Schristos  * $Id: j_events.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
7*e137d3e0Schristos  *
8*e137d3e0Schristos  * This traces activity from all Java processes on the system with hotspot
9*e137d3e0Schristos  * provider support (1.6.0). Some events such as method calls are only
10*e137d3e0Schristos  * visible when using the flag "+ExtendedDTraceProbes". eg,
11*e137d3e0Schristos  * java -XX:+ExtendedDTraceProbes classfile
12*e137d3e0Schristos  *
13*e137d3e0Schristos  * USAGE: j_events.d 		# hit Ctrl-C to end
14*e137d3e0Schristos  *
15*e137d3e0Schristos  * FIELDS:
16*e137d3e0Schristos  *		PID		Process ID
17*e137d3e0Schristos  *		EVENT		Event name (DTrace probe name)
18*e137d3e0Schristos  *		COUNT		Number of calls during sample
19*e137d3e0Schristos  *
20*e137d3e0Schristos  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
21*e137d3e0Schristos  *
22*e137d3e0Schristos  * CDDL HEADER START
23*e137d3e0Schristos  *
24*e137d3e0Schristos  *  The contents of this file are subject to the terms of the
25*e137d3e0Schristos  *  Common Development and Distribution License, Version 1.0 only
26*e137d3e0Schristos  *  (the "License").  You may not use this file except in compliance
27*e137d3e0Schristos  *  with the License.
28*e137d3e0Schristos  *
29*e137d3e0Schristos  *  You can obtain a copy of the license at Docs/cddl1.txt
30*e137d3e0Schristos  *  or http://www.opensolaris.org/os/licensing.
31*e137d3e0Schristos  *  See the License for the specific language governing permissions
32*e137d3e0Schristos  *  and limitations under the License.
33*e137d3e0Schristos  *
34*e137d3e0Schristos  * CDDL HEADER END
35*e137d3e0Schristos  *
36*e137d3e0Schristos  * 09-Sep-2007	Brendan Gregg	Created this.
37*e137d3e0Schristos  */
38*e137d3e0Schristos 
39*e137d3e0Schristos #pragma D option quiet
40*e137d3e0Schristos 
41*e137d3e0Schristos dtrace:::BEGIN
42*e137d3e0Schristos {
43*e137d3e0Schristos 	printf("Tracing... Hit Ctrl-C to end.\n");
44*e137d3e0Schristos }
45*e137d3e0Schristos 
46*e137d3e0Schristos /* this matches both hotspot and hotspot_jni providers */
47*e137d3e0Schristos hotspot*:::
48*e137d3e0Schristos {
49*e137d3e0Schristos 	@calls[pid, probename] = count();
50*e137d3e0Schristos }
51*e137d3e0Schristos 
52*e137d3e0Schristos dtrace:::END
53*e137d3e0Schristos {
54*e137d3e0Schristos 	printf(" %6s  %-36s %8s\n", "PID", "EVENT", "COUNT");
55*e137d3e0Schristos 	printa(" %6d  %-36s %@8d\n", @calls);
56*e137d3e0Schristos }
57