1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * iofileb.d - I/O bytes by filename and process. 4235368Sgnn * Written using DTrace (Solaris 10 3/05). 5235368Sgnn * 6235368Sgnn * This prints a summary of requested disk activity by pathname, 7235368Sgnn * providing totals of the I/O events in bytes. It is a companion to the 8235368Sgnn * iofile.d script - which prints in terms of I/O wait time, not bytes. 9235368Sgnn * I/O wait time is a better metric for understanding performance issues. 10235368Sgnn * Both disk and NFS I/O are measured. 11235368Sgnn * 12235368Sgnn * $Id: iofileb.d 3 2007-08-01 10:50:08Z brendan $ 13235368Sgnn * 14235368Sgnn * USAGE: iofileb.d # wait several seconds, then hit Ctrl-C 15235368Sgnn * 16235368Sgnn * FIELDS: 17235368Sgnn * PID process ID 18235368Sgnn * CMD command name 19235368Sgnn * KB Kilobytes of disk I/O 20235368Sgnn * FILE Full pathname of the file 21235368Sgnn * 22235368Sgnn * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. 23235368Sgnn * 24235368Sgnn * CDDL HEADER START 25235368Sgnn * 26235368Sgnn * The contents of this file are subject to the terms of the 27235368Sgnn * Common Development and Distribution License, Version 1.0 only 28235368Sgnn * (the "License"). You may not use this file except in compliance 29235368Sgnn * with the License. 30235368Sgnn * 31235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 32235368Sgnn * or http://www.opensolaris.org/os/licensing. 33235368Sgnn * See the License for the specific language governing permissions 34235368Sgnn * and limitations under the License. 35235368Sgnn * 36235368Sgnn * CDDL HEADER END 37235368Sgnn * 38235368Sgnn * 20-Feb-2006 Brendan Gregg Created this. 39235368Sgnn * 20-Feb-2006 " " Last update. 40235368Sgnn */ 41235368Sgnn 42235368Sgnn#pragma D option quiet 43235368Sgnn 44235368Sgnndtrace:::BEGIN 45235368Sgnn{ 46235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 47235368Sgnn} 48235368Sgnn 49235368Sgnnio:::start 50235368Sgnn{ 51235368Sgnn @files[pid, execname, args[2]->fi_pathname] = sum(args[0]->b_bcount); 52235368Sgnn} 53235368Sgnn 54235368Sgnndtrace:::END 55235368Sgnn{ 56235368Sgnn normalize(@files, 1024); 57235368Sgnn printf("%6s %-12s %6s %s\n", "PID", "CMD", "KB", "FILE"); 58235368Sgnn printa("%6d %-12.12s %@6d %s\n", @files); 59235368Sgnn} 60