j_who.d revision 235368
1235368Sgnn#!/usr/sbin/dtrace -Zs 2235368Sgnn/* 3235368Sgnn * j_who.d - trace Java calls by process using DTrace. 4235368Sgnn * Written for the Java hotspot DTrace provider. 5235368Sgnn * 6235368Sgnn * $Id: j_who.d 19 2007-09-12 07:47:59Z brendan $ 7235368Sgnn * 8235368Sgnn * This traces activity from all Java processes on the system with hotspot 9235368Sgnn * provider support (1.6.0). 10235368Sgnn * 11235368Sgnn * USAGE: j_who.d # hit Ctrl-C to end 12235368Sgnn * 13235368Sgnn * FIELDS: 14235368Sgnn * PID Process ID of Java 15235368Sgnn * UID User ID of the owner 16235368Sgnn * CALLS Number of calls made (a measure of activity) 17235368Sgnn * ARGS Process name and arguments 18235368Sgnn * 19235368Sgnn * The argument list is truncated at 55 characters (up to 80 is easily 20235368Sgnn * available). To easily read the full argument list, use other system tools; 21235368Sgnn * on Solaris use "pargs PID". 22235368Sgnn * 23235368Sgnn * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 24235368Sgnn * 25235368Sgnn * CDDL HEADER START 26235368Sgnn * 27235368Sgnn * The contents of this file are subject to the terms of the 28235368Sgnn * Common Development and Distribution License, Version 1.0 only 29235368Sgnn * (the "License"). You may not use this file except in compliance 30235368Sgnn * with the License. 31235368Sgnn * 32235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 33235368Sgnn * or http://www.opensolaris.org/os/licensing. 34235368Sgnn * See the License for the specific language governing permissions 35235368Sgnn * and limitations under the License. 36235368Sgnn * 37235368Sgnn * CDDL HEADER END 38235368Sgnn * 39235368Sgnn * 09-Sep-2007 Brendan Gregg Created this. 40235368Sgnn */ 41235368Sgnn 42235368Sgnn#pragma D option quiet 43235368Sgnn 44235368Sgnndtrace:::BEGIN 45235368Sgnn{ 46235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 47235368Sgnn} 48235368Sgnn 49235368Sgnnhotspot*:::Call*-entry 50235368Sgnn{ 51235368Sgnn @calls[pid, uid, curpsinfo->pr_psargs] = count(); 52235368Sgnn} 53235368Sgnn 54235368Sgnndtrace:::END 55235368Sgnn{ 56235368Sgnn printf(" %6s %6s %6s %-55s\n", "PID", "UID", "CALLS", "ARGS"); 57235368Sgnn printa(" %6d %6d %@6d %-55.55s\n", @calls); 58235368Sgnn} 59