1#!/usr/sbin/dtrace -s
2/*
3 * iofileb.d - I/O bytes by filename and process.
4 *             Written using DTrace (Solaris 10 3/05).
5 *
6 * This prints a summary of requested disk activity by pathname,
7 * providing totals of the I/O events in bytes. It is a companion to the
8 * iofile.d script - which prints in terms of I/O wait time, not bytes.
9 * I/O wait time is a better metric for understanding performance issues.
10 * Both disk and NFS I/O are measured.
11 *
12 * 20-Feb-2006, ver 1.00
13 *
14 * USAGE:	iofileb.d	# wait several seconds, then hit Ctrl-C
15 *
16 * FIELDS:
17 *		PID	process ID
18 *		CMD	command name
19 *		KB	Kilobytes of disk I/O
20 *		FILE	Full pathname of the file
21 *
22 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
23 *
24 * CDDL HEADER START
25 *
26 *  The contents of this file are subject to the terms of the
27 *  Common Development and Distribution License, Version 1.0 only
28 *  (the "License").  You may not use this file except in compliance
29 *  with the License.
30 *
31 *  You can obtain a copy of the license at Docs/cddl1.txt
32 *  or http://www.opensolaris.org/os/licensing.
33 *  See the License for the specific language governing permissions
34 *  and limitations under the License.
35 *
36 * CDDL HEADER END
37 *
38 * 20-Feb-2006	Brendan Gregg	Created this.
39 */
40
41#pragma D option quiet
42
43dtrace:::BEGIN
44{
45	printf("Tracing... Hit Ctrl-C to end.\n");
46}
47
48io:::start
49{
50	@files[pid, execname, args[2]->fi_pathname] = sum(args[0]->b_bcount);
51}
52
53dtrace:::END
54{
55	normalize(@files, 1024);
56	printf("%6s %-12s %6s %s\n", "PID", "CMD", "KB", "FILE");
57	printa("%6d %-12.12s %@6d %s\n", @files);
58}
59
60