3 * iofile.d - I/O wait time by filename and process.
4 * Written using DTrace (Solaris 10 3/05).
6 * This prints the total I/O wait times for each filename by process.
7 * This can help determine why an application is performing poorly by
8 * identifying which file they are waiting on, and the total times.
9 * Both disk and NFS I/O are measured.
11 * $Id: iofile.d 3 2007-08-01 10:50:08Z brendan $
13 * USAGE: iofile.d # wait, then hit Ctrl-C to end
18 * TIME Total wait time for disk events, us
21 * BASED ON: /usr/demo/dtrace/iocpu.d
23 * SEE ALSO: iosnoop, iotop
25 * PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg.
29 * The contents of this file are subject to the terms of the
30 * Common Development and Distribution License, Version 1.0 only
31 * (the "License"). You may not use this file except in compliance
34 * You can obtain a copy of the license at Docs/cddl1.txt
35 * or http://www.opensolaris.org/os/licensing.
36 * See the License for the specific language governing permissions
37 * and limitations under the License.
41 * 24-Jul-2005 Brendan Gregg Created this.
42 * 20-Apr-2006 " " Last update.
45 #pragma D option quiet
50 printf("Tracing... Hit Ctrl-C to end.\n");
53 /* save time at start */
56 self->start = timestamp;
64 * wait-done is used as we are measing wait times. It also
65 * is triggered when the correct thread is on the CPU, obviating
66 * the need to link process details to the start event.
68 this->elapsed = timestamp - self->start;
69 @files[pid, execname, args[2]->fi_pathname] = sum(this->elapsed);
76 normalize(@files, 1000);
77 printf("%6s %-12s %8s %s\n", "PID", "CMD", "TIME", "FILE");
78 printa("%6d %-12.12s %@8d %s\n", @files);