1#!/usr/sbin/dtrace -s 2/* 3 * bitesize.d - analyse disk I/O size by process. 4 * Written using DTrace (Solaris 10 3/05). 5 * 6 * This produces a report for the size of disk events caused by 7 * processes. These are the disk events sent by the block I/O driver. 8 * 9 * If applications must use the disks, we generally prefer they do so 10 * with large I/O sizes. 11 * 12 * $Id: bitesize.d 3 2007-08-01 10:50:08Z brendan $ 13 * 14 * USAGE: bitesize.d # wait several seconds, then hit Ctrl-C 15 * 16 * FIELDS: 17 * PID process ID 18 * CMD command and argument list 19 * value size in bytes 20 * count number of I/O operations 21 * 22 * NOTES: 23 * 24 * The application may be requesting smaller sized operations, which 25 * are being rounded up to the nearest sector size or UFS block size. 26 * To analyse what the application is requesting, DTraceToolkit programs 27 * such as Proc/fddist may help. 28 * 29 * SEE ALSO: seeksize.d, iosnoop 30 * 31 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. 32 * 33 * CDDL HEADER START 34 * 35 * The contents of this file are subject to the terms of the 36 * Common Development and Distribution License, Version 1.0 only 37 * (the "License"). You may not use this file except in compliance 38 * with the License. 39 * 40 * You can obtain a copy of the license at Docs/cddl1.txt 41 * or http://www.opensolaris.org/os/licensing. 42 * See the License for the specific language governing permissions 43 * and limitations under the License. 44 * 45 * CDDL HEADER END 46 * 47 * 31-Mar-2004 Brendan Gregg Created this, build 51. 48 * 10-Oct-2004 " " Rewrote to use the io provider, build 63. 49 * 18-Feb-2006 " " Last update. 50 */ 51 52#pragma D option quiet 53 54/* 55 * Print header 56 */ 57dtrace:::BEGIN 58{ 59 printf("Tracing... Hit Ctrl-C to end.\n"); 60} 61 62/* 63 * Process io start 64 */ 65io:::start 66{ 67 /* fetch details */ 68 this->size = args[0]->b_bcount; 69 70 /* store details */ 71 @Size[pid, curpsinfo->pr_psargs] = quantize(this->size); 72} 73 74/* 75 * Print final report 76 */ 77dtrace:::END 78{ 79 printf("\n%8s %s\n", "PID", "CMD"); 80 printa("%8d %S\n%@d\n", @Size); 81} 82