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