1N/A#!/usr/sbin/dtrace -s
1N/A/*
1N/A * nfswizard.d - nfs client activity wizard.
1N/A * Written using DTrace (Solaris 10 3/05).
1N/A *
1N/A * This examines activity caused by NFS client processes on the same server
1N/A * that you are running this script on. A detailed report is generated
1N/A * to explain various details of NFS client activity, including response
1N/A * times and file access.
1N/A *
1N/A * $Id: nfswizard.d 3 2007-08-01 10:50:08Z brendan $
1N/A *
1N/A * USAGE: nfswizard.d # hit Ctrl-C to end sample
1N/A *
1N/A * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
1N/A *
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License, Version 1.0 only
1N/A * (the "License"). You may not use this file except in compliance
1N/A * with the License.
1N/A *
1N/A * You can obtain a copy of the license at Docs/cddl1.txt
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * CDDL HEADER END
1N/A *
1N/A * 02-Dec-2005 Brendan Gregg Created this.
1N/A * 20-Apr-2006 " " Last update.
1N/A */
1N/A
1N/A#pragma D option quiet
1N/A
1N/Adtrace:::BEGIN
1N/A{
1N/A printf("Tracing... Hit Ctrl-C to end.\n");
1N/A scriptstart = walltimestamp;
1N/A timestart = timestamp;
1N/A}
1N/A
1N/Aio:nfs::start
1N/A{
1N/A /* tally file sizes */
1N/A @file[args[2]->fi_pathname] = sum(args[0]->b_bcount);
1N/A
1N/A /* time response */
1N/A start[args[0]->b_addr] = timestamp;
1N/A
1N/A /* overall stats */
1N/A @rbytes = sum(args[0]->b_flags & B_READ ? args[0]->b_bcount : 0);
1N/A @wbytes = sum(args[0]->b_flags & B_READ ? 0 : args[0]->b_bcount);
1N/A @events = count();
1N/A}
1N/A
1N/Aio:nfs::done
1N/A/start[args[0]->b_addr]/
1N/A{
1N/A /* calculate and save response time stats */
1N/A this->elapsed = timestamp - start[args[0]->b_addr];
1N/A @maxtime = max(this->elapsed);
1N/A @avgtime = avg(this->elapsed);
1N/A @qnztime = quantize(this->elapsed / 1000);
1N/A}
1N/A
1N/Adtrace:::END
1N/A{
1N/A /* print header */
1N/A printf("NFS Client Wizard. %Y -> %Y\n\n", scriptstart, walltimestamp);
1N/A
1N/A /* print read/write stats */
1N/A printa("Read: %@d bytes ", @rbytes);
1N/A normalize(@rbytes, 1000000);
1N/A printa("(%@d Mb)\n", @rbytes);
1N/A printa("Write: %@d bytes ", @wbytes);
1N/A normalize(@wbytes, 1000000);
1N/A printa("(%@d Mb)\n\n", @wbytes);
1N/A
1N/A /* print throughput stats */
1N/A denormalize(@rbytes);
1N/A normalize(@rbytes, (timestamp - timestart) / 1000000);
1N/A printa("Read: %@d Kb/sec\n", @rbytes);
1N/A denormalize(@wbytes);
1N/A normalize(@wbytes, (timestamp - timestart) / 1000000);
1N/A printa("Write: %@d Kb/sec\n\n", @wbytes);
1N/A
1N/A /* print time stats */
1N/A printa("NFS I/O events: %@d\n", @events);
1N/A normalize(@avgtime, 1000000);
1N/A printa("Avg response time: %@d ms\n", @avgtime);
1N/A normalize(@maxtime, 1000000);
1N/A printa("Max response time: %@d ms\n\n", @maxtime);
1N/A printa("Response times (us):%@d\n", @qnztime);
1N/A
1N/A /* print file stats */
1N/A printf("Top 25 files accessed (bytes):\n");
1N/A printf(" %-64s %s\n", "PATHNAME", "BYTES");
1N/A trunc(@file, 25);
1N/A printa(" %-64s %@d\n", @file);
1N/A}