1*c29d5175Schristos #!/usr/sbin/dtrace -s 2*c29d5175Schristos /* 3*c29d5175Schristos * syscallbypid.d - report on syscalls by PID. 4*c29d5175Schristos * Written using DTrace (Solaris 10 3/05) 5*c29d5175Schristos * 6*c29d5175Schristos * $Id: syscallbypid.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $ 7*c29d5175Schristos * 8*c29d5175Schristos * USAGE: syscallbypid.d # hit Ctrl-C to end sample 9*c29d5175Schristos * 10*c29d5175Schristos * FIELDS: 11*c29d5175Schristos * PID process ID 12*c29d5175Schristos * CMD process name 13*c29d5175Schristos * SYSCALL syscall name 14*c29d5175Schristos * COUNT number of syscalls for this PID 15*c29d5175Schristos * 16*c29d5175Schristos * This is based on a script from DExplorer. 17*c29d5175Schristos * 18*c29d5175Schristos * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. 19*c29d5175Schristos * 20*c29d5175Schristos * CDDL HEADER START 21*c29d5175Schristos * 22*c29d5175Schristos * The contents of this file are subject to the terms of the 23*c29d5175Schristos * Common Development and Distribution License, Version 1.0 only 24*c29d5175Schristos * (the "License"). You may not use this file except in compliance 25*c29d5175Schristos * with the License. 26*c29d5175Schristos * 27*c29d5175Schristos * You can obtain a copy of the license at Docs/cddl1.txt 28*c29d5175Schristos * or http://www.opensolaris.org/os/licensing. 29*c29d5175Schristos * See the License for the specific language governing permissions 30*c29d5175Schristos * and limitations under the License. 31*c29d5175Schristos * 32*c29d5175Schristos * CDDL HEADER END 33*c29d5175Schristos * 34*c29d5175Schristos * 15-May-2005 Brendan Gregg Created this. 35*c29d5175Schristos * 20-Apr-2006 " " Last update. 36*c29d5175Schristos */ 37*c29d5175Schristos 38*c29d5175Schristos #pragma D option quiet 39*c29d5175Schristos 40*c29d5175Schristos dtrace:::BEGIN 41*c29d5175Schristos { 42*c29d5175Schristos printf("Tracing... Hit Ctrl-C to end.\n"); 43*c29d5175Schristos } 44*c29d5175Schristos 45*c29d5175Schristos syscall:::entry 46*c29d5175Schristos { 47*c29d5175Schristos @num[pid, execname, probefunc] = count(); 48*c29d5175Schristos } 49*c29d5175Schristos 50*c29d5175Schristos dtrace:::END 51*c29d5175Schristos { 52*c29d5175Schristos printf("%6s %-24s %-24s %8s\n", "PID", "CMD", "SYSCALL", "COUNT"); 53*c29d5175Schristos printa("%6d %-24s %-24s %@8d\n", @num); 54*c29d5175Schristos } 55