3 * nfswizard.d - nfs client activity wizard.
4 * Written using DTrace (Solaris 10 3/05).
6 * This examines activity caused by NFS client processes on the same server
7 * that you are running this script on. A detailed report is generated
8 * to explain various details of NFS client activity, including response
9 * times and file access.
11 * $Id: nfswizard.d 3 2007-08-01 10:50:08Z brendan $
13 * USAGE: nfswizard.d # hit Ctrl-C to end sample
15 * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
19 * The contents of this file are subject to the terms of the
20 * Common Development and Distribution License, Version 1.0 only
21 * (the "License"). You may not use this file except in compliance
24 * You can obtain a copy of the license at Docs/cddl1.txt
25 * or http://www.opensolaris.org/os/licensing.
26 * See the License for the specific language governing permissions
27 * and limitations under the License.
31 * 02-Dec-2005 Brendan Gregg Created this.
32 * 20-Apr-2006 " " Last update.
35 #pragma D option quiet
39 printf("Tracing... Hit Ctrl-C to end.\n");
40 scriptstart = walltimestamp;
41 timestart = timestamp;
46 /* tally file sizes */
47 @file[args[2]->fi_pathname] = sum(args[0]->b_bcount);
50 start[args[0]->b_addr] = timestamp;
53 @rbytes = sum(args[0]->b_flags & B_READ ? args[0]->b_bcount : 0);
54 @wbytes = sum(args[0]->b_flags & B_READ ? 0 : args[0]->b_bcount);
59 /start[args[0]->b_addr]/
61 /* calculate and save response time stats */
62 this->elapsed = timestamp - start[args[0]->b_addr];
63 @maxtime = max(this->elapsed);
64 @avgtime = avg(this->elapsed);
65 @qnztime = quantize(this->elapsed / 1000);
71 printf("NFS Client Wizard. %Y -> %Y\n\n", scriptstart, walltimestamp);
73 /* print read/write stats */
74 printa("Read: %@d bytes ", @rbytes);
75 normalize(@rbytes, 1000000);
76 printa("(%@d Mb)\n", @rbytes);
77 printa("Write: %@d bytes ", @wbytes);
78 normalize(@wbytes, 1000000);
79 printa("(%@d Mb)\n\n", @wbytes);
81 /* print throughput stats */
83 normalize(@rbytes, (timestamp - timestart) / 1000000);
84 printa("Read: %@d Kb/sec\n", @rbytes);
86 normalize(@wbytes, (timestamp - timestart) / 1000000);
87 printa("Write: %@d Kb/sec\n\n", @wbytes);
89 /* print time stats */
90 printa("NFS I/O events: %@d\n", @events);
91 normalize(@avgtime, 1000000);
92 printa("Avg response time: %@d ms\n", @avgtime);
93 normalize(@maxtime, 1000000);
94 printa("Max response time: %@d ms\n\n", @maxtime);
95 printa("Response times (us):%@d\n", @qnztime);
97 /* print file stats */
98 printf("Top 25 files accessed (bytes):\n");
99 printf(" %-64s %s\n", "PATHNAME", "BYTES");
101 printa(" %-64s %@d\n", @file);