1N/A#!/usr/sbin/dtrace -s
1N/A/*
1N/A * rfsio.d - read FS I/O stats, with cache miss rate.
1N/A * Written using DTrace (Solaris 10 3/05)
1N/A *
1N/A * This script provides statistics on the number of reads and the bytes
1N/A * read from filesystems (logical), and the number of bytes read from
1N/A * disk (physical). A summary is printed every five seconds by filesystem.
1N/A *
1N/A * A total miss-rate is also provided for the file system cache.
1N/A *
1N/A * $Id: rfsio.d 3 2007-08-01 10:50:08Z brendan $
1N/A *
1N/A * USAGE: rfsio.d
1N/A *
1N/A * IDEA: Richard McDougall, Solaris Internals 2nd Ed, FS Chapter.
1N/A *
1N/A * COPYRIGHT: Copyright (c) 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 * 19-Mar-2006 Brendan Gregg Created this.
1N/A * 23-Apr-2006 " " Last update.
1N/A */
1N/A
1N/A#pragma D option quiet
1N/A
1N/Aself int trace;
1N/Auint64_t lbytes;
1N/Auint64_t pbytes;
1N/A
1N/Adtrace:::BEGIN
1N/A{
1N/A trace("Tracing...\n");
1N/A}
1N/A
1N/Afbt::fop_read:entry
1N/A/self->trace == 0/
1N/A{
1N/A self->fs_mount = args[0]->v_vfsp == `rootvfs ? "/" :
1N/A args[0]->v_vfsp->vfs_vnodecovered ?
1N/A stringof(args[0]->v_vfsp->vfs_vnodecovered->v_path) : NULL;
1N/A}
1N/A
1N/Afbt::fop_read:entry
1N/A/self->fs_mount != NULL/
1N/A{
1N/A @rio[self->fs_mount, "logical"] = count();
1N/A lbytes += args[1]->uio_resid;
1N/A self->size = args[1]->uio_resid;
1N/A self->uiop = args[1];
1N/A}
1N/A
1N/Afbt::fop_read:return
1N/A/self->size/
1N/A{
1N/A @rbytes[self->fs_mount, "logical"] =
1N/A sum(self->size - self->uiop->uio_resid);
1N/A self->size = 0;
1N/A self->uiop = 0;
1N/A self->fs_mount = 0;
1N/A}
1N/A
1N/Aio::bdev_strategy:start
1N/A/self->size && args[0]->b_flags & B_READ/
1N/A{
1N/A @rio[self->fs_mount, "physical"] = count();
1N/A @rbytes[self->fs_mount, "physical"] = sum(args[0]->b_bcount);
1N/A pbytes += args[0]->b_bcount;
1N/A}
1N/A
1N/Aprofile:::tick-5s
1N/A{
1N/A trunc(@rio, 20);
1N/A trunc(@rbytes, 20);
1N/A printf("\033[H\033[2J");
1N/A printf("\nRead IOPS (count)\n");
1N/A printa("%-32s %10s %10@d\n", @rio);
1N/A printf("\nRead Bandwidth (bytes)\n");
1N/A printa("%-32s %10s %10@d\n", @rbytes);
1N/A printf("\nTotal File System miss-rate: %d%%\n",
1N/A lbytes ? 100 * pbytes / lbytes : 0);
1N/A trunc(@rbytes);
1N/A trunc(@rio);
1N/A lbytes = pbytes = 0;
1N/A}