1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * minfbypid.d - minor faults by PID. 4235368Sgnn * Written using DTrace (Solaris 10 3/05) 5235368Sgnn * 6235368Sgnn * This program prints a report of minor faults by PID. Minor faults are 7235368Sgnn * an indiction of memory consumption. This script could be used to help 8235368Sgnn * determine which process was consuming the most memory during the sample. 9235368Sgnn * 10235368Sgnn * $Id: minfbypid.d 3 2007-08-01 10:50:08Z brendan $ 11235368Sgnn * 12235368Sgnn * USAGE: minfbypid.d # hit Ctrl-C to end sample 13235368Sgnn * 14235368Sgnn * FIELDS: 15235368Sgnn * PID process ID 16235368Sgnn * CMD process name 17235368Sgnn * MINFAULTS number of minor faults 18235368Sgnn * 19235368Sgnn * This is based on a script from DExplorer. 20235368Sgnn * 21235368Sgnn * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. 22235368Sgnn * 23235368Sgnn * CDDL HEADER START 24235368Sgnn * 25235368Sgnn * The contents of this file are subject to the terms of the 26235368Sgnn * Common Development and Distribution License, Version 1.0 only 27235368Sgnn * (the "License"). You may not use this file except in compliance 28235368Sgnn * with the License. 29235368Sgnn * 30235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 31235368Sgnn * or http://www.opensolaris.org/os/licensing. 32235368Sgnn * See the License for the specific language governing permissions 33235368Sgnn * and limitations under the License. 34235368Sgnn * 35235368Sgnn * CDDL HEADER END 36235368Sgnn * 37235368Sgnn * 28-Jun-2005 Brendan Gregg Created this. 38235368Sgnn * 20-Apr-2006 " " Last update. 39235368Sgnn */ 40235368Sgnn 41235368Sgnn#pragma D option quiet 42235368Sgnn 43235368Sgnndtrace:::BEGIN 44235368Sgnn{ 45235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 46235368Sgnn} 47235368Sgnn 48235368Sgnnvminfo:::as_fault 49235368Sgnn{ 50235368Sgnn @mem[pid, execname] = sum(arg0); 51235368Sgnn} 52235368Sgnn 53235368Sgnndtrace:::END 54235368Sgnn{ 55235368Sgnn printf("%6s %-16s %16s\n", "PID", "CMD", "MINFAULTS"); 56235368Sgnn printa("%6d %-16s %@16d\n", @mem); 57235368Sgnn} 58