1235368Sgnn#!/usr/sbin/dtrace -s 2235368Sgnn/* 3235368Sgnn * bitesize.d - analyse disk I/O size by process. 4235368Sgnn * Written using DTrace (Solaris 10 3/05). 5235368Sgnn * 6235368Sgnn * This produces a report for the size of disk events caused by 7235368Sgnn * processes. These are the disk events sent by the block I/O driver. 8235368Sgnn * 9235368Sgnn * If applications must use the disks, we generally prefer they do so 10235368Sgnn * with large I/O sizes. 11235368Sgnn * 12235368Sgnn * $Id: bitesize.d 3 2007-08-01 10:50:08Z brendan $ 13235368Sgnn * 14235368Sgnn * USAGE: bitesize.d # wait several seconds, then hit Ctrl-C 15235368Sgnn * 16235368Sgnn * FIELDS: 17235368Sgnn * PID process ID 18235368Sgnn * CMD command and argument list 19235368Sgnn * value size in bytes 20235368Sgnn * count number of I/O operations 21235368Sgnn * 22235368Sgnn * NOTES: 23235368Sgnn * 24235368Sgnn * The application may be requesting smaller sized operations, which 25235368Sgnn * are being rounded up to the nearest sector size or UFS block size. 26235368Sgnn * To analyse what the application is requesting, DTraceToolkit programs 27235368Sgnn * such as Proc/fddist may help. 28235368Sgnn * 29235368Sgnn * SEE ALSO: seeksize.d, iosnoop 30235368Sgnn * 31235368Sgnn * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. 32235368Sgnn * 33235368Sgnn * CDDL HEADER START 34235368Sgnn * 35235368Sgnn * The contents of this file are subject to the terms of the 36235368Sgnn * Common Development and Distribution License, Version 1.0 only 37235368Sgnn * (the "License"). You may not use this file except in compliance 38235368Sgnn * with the License. 39235368Sgnn * 40235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 41235368Sgnn * or http://www.opensolaris.org/os/licensing. 42235368Sgnn * See the License for the specific language governing permissions 43235368Sgnn * and limitations under the License. 44235368Sgnn * 45235368Sgnn * CDDL HEADER END 46235368Sgnn * 47235368Sgnn * 31-Mar-2004 Brendan Gregg Created this, build 51. 48235368Sgnn * 10-Oct-2004 " " Rewrote to use the io provider, build 63. 49235368Sgnn * 18-Feb-2006 " " Last update. 50235368Sgnn */ 51235368Sgnn 52235368Sgnn#pragma D option quiet 53235368Sgnn 54235368Sgnn/* 55235368Sgnn * Print header 56235368Sgnn */ 57235368Sgnndtrace:::BEGIN 58235368Sgnn{ 59235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 60235368Sgnn} 61235368Sgnn 62235368Sgnn/* 63235368Sgnn * Process io start 64235368Sgnn */ 65235368Sgnnio:::start 66235368Sgnn{ 67235368Sgnn /* fetch details */ 68235368Sgnn this->size = args[0]->b_bcount; 69235368Sgnn 70235368Sgnn /* store details */ 71235368Sgnn @Size[pid, curpsinfo->pr_psargs] = quantize(this->size); 72235368Sgnn} 73235368Sgnn 74235368Sgnn/* 75235368Sgnn * Print final report 76235368Sgnn */ 77235368Sgnndtrace:::END 78235368Sgnn{ 79235368Sgnn printf("\n%8s %s\n", "PID", "CMD"); 80235368Sgnn printa("%8d %S\n%@d\n", @Size); 81235368Sgnn} 82