1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * sysbypid.d - print sysinfo events by process. 4235368Sgnn * Uses DTrace (Solaris 10 3/05). 5235368Sgnn * 6235368Sgnn * $Id: sysbypid.d 3 2007-08-01 10:50:08Z brendan $ 7235368Sgnn * 8235368Sgnn * USAGE: sysbypid.d 9235368Sgnn * 10235368Sgnn * FIELDS: 11235368Sgnn * EXEC Process name 12235368Sgnn * PID Process ID 13235368Sgnn * SYS System statistic (see /usr/include/sys/sysinfo.h) 14235368Sgnn * VALUE Value by which statistic was incremented 15235368Sgnn * 16235368Sgnn * The virtual memory statistics are documented in the cpu_sysinfo struct 17235368Sgnn * in the /usr/include/sys/sysinfo.h file; and also in the sysinfo provider 18235368Sgnn * chapter of the DTrace Guide, http://docs.sun.com/db/doc/817-6223. 19235368Sgnn * 20235368Sgnn * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. 21235368Sgnn * 22235368Sgnn * CDDL HEADER START 23235368Sgnn * 24235368Sgnn * The contents of this file are subject to the terms of the 25235368Sgnn * Common Development and Distribution License, Version 1.0 only 26235368Sgnn * (the "License"). You may not use this file except in compliance 27235368Sgnn * with the License. 28235368Sgnn * 29235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 30235368Sgnn * or http://www.opensolaris.org/os/licensing. 31235368Sgnn * See the License for the specific language governing permissions 32235368Sgnn * and limitations under the License. 33235368Sgnn * 34235368Sgnn * CDDL HEADER END 35235368Sgnn * 36235368Sgnn * 14-May-2005 Brendan Gregg Created this. 37235368Sgnn * 20-Apr-2006 " " Last update. 38235368Sgnn */ 39235368Sgnn 40235368Sgnn#pragma D option quiet 41235368Sgnn 42235368Sgnndtrace:::BEGIN { 43235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 44235368Sgnn} 45235368Sgnn 46235368Sgnnsysinfo::: { 47235368Sgnn @Sys[execname, pid, probename] = sum(arg0); 48235368Sgnn} 49235368Sgnn 50235368Sgnndtrace:::END { 51235368Sgnn printf("%16s %8s %22s %8s\n", "EXEC", "PID", "SYS", "VALUE"); 52235368Sgnn printa("%16s %8d %22s %@8d\n", @Sys); 53235368Sgnn} 54