1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * mmapfiles.d - mmap'd files by process. 4235368Sgnn * Written using DTrace (Solaris 10 3/05). 5235368Sgnn * 6235368Sgnn * $Id: mmapfiles.d 14 2007-09-11 08:03:35Z brendan $ 7235368Sgnn * 8235368Sgnn * USAGE: mmapfiles.d # hit Ctrl-C to end sample 9235368Sgnn * 10235368Sgnn * FIELDS: 11235368Sgnn * MMAPS number of mmaps 12235368Sgnn * CMD process name 13235368Sgnn * PATHNAME pathname of mmap'd file 14235368Sgnn * 15235368Sgnn * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. 16235368Sgnn * 17235368Sgnn * CDDL HEADER START 18235368Sgnn * 19235368Sgnn * The contents of this file are subject to the terms of the 20235368Sgnn * Common Development and Distribution License, Version 1.0 only 21235368Sgnn * (the "License"). You may not use this file except in compliance 22235368Sgnn * with the License. 23235368Sgnn * 24235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 25235368Sgnn * or http://www.opensolaris.org/os/licensing. 26235368Sgnn * See the License for the specific language governing permissions 27235368Sgnn * and limitations under the License. 28235368Sgnn * 29235368Sgnn * CDDL HEADER END 30235368Sgnn * 31235368Sgnn * 18-Oct-2005 Brendan Gregg Created this. 32235368Sgnn * 20-Apr-2006 " " Last update. 33235368Sgnn */ 34235368Sgnn 35235368Sgnn#pragma D option quiet 36235368Sgnn 37235368Sgnndtrace:::BEGIN 38235368Sgnn{ 39235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 40235368Sgnn} 41235368Sgnn 42235368Sgnnsyscall::mmap:entry 43235368Sgnn/(int)arg4 > 0/ 44235368Sgnn{ 45235368Sgnn /* 46235368Sgnn * Fetch filename 47235368Sgnn */ 48235368Sgnn this->filep = curthread->t_procp->p_user.u_finfo.fi_list[arg4].uf_file; 49235368Sgnn this->vnodep = this->filep != 0 ? this->filep->f_vnode : 0; 50235368Sgnn self->vpath = this->vnodep ? (this->vnodep->v_path != 0 ? 51235368Sgnn cleanpath(this->vnodep->v_path) : "<unknown>") : "<unknown>"; 52235368Sgnn 53235368Sgnn /* Store Details */ 54235368Sgnn @hits[execname, self->vpath] = count(); 55235368Sgnn} 56235368Sgnn 57235368Sgnndtrace:::END 58235368Sgnn{ 59235368Sgnn /* Print Details */ 60235368Sgnn printf("%5s %-16s %s\n", "MMAPS", "CMD", "PATHNAME"); 61235368Sgnn printa("%@5d %-16s %s\n", @hits); 62235368Sgnn} 63