3 * rwbytype.d - read/write bytes by vnode type.
4 * Written using DTrace (Solaris 10 3/05).
6 * This program identifies the vnode type of read/write activity - whether
7 * that is for regular files, sockets, character special devices, etc.
9 * $Id: rwbytype.d 3 2007-08-01 10:50:08Z brendan $
11 * USAGE: rwbytype.d # hit Ctrl-C to end sample
14 * PID number of rwbytype
16 * VTYPE vnode type (describes I/O type)
17 * DIR direction (Read/Write)
18 * BYTES bytes transferred
20 * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
24 * The contents of this file are subject to the terms of the
25 * Common Development and Distribution License, Version 1.0 only
26 * (the "License"). You may not use this file except in compliance
29 * You can obtain a copy of the license at Docs/cddl1.txt
30 * or http://www.opensolaris.org/os/licensing.
31 * See the License for the specific language governing permissions
32 * and limitations under the License.
36 * 18-Oct-2005 Brendan Gregg Created this.
37 * 20-Apr-2006 " " Last update.
40 #pragma D option quiet
42 typedef struct vtype2str {
46 translator struct vtype2str < int T > {
47 /* the order has been picked for performance reasons */
59 T == 11 ? "bad" : "non";
64 printf("Tracing... Hit Ctrl-C to end.\n");
70 self->type = xlate <struct vtype2str *>(args[0]->v_type)->code;
71 self->size = args[1]->uio_resid;
78 this->resid = self->uiop->uio_resid;
79 @bytes[pid, execname, self->type, "R"] = sum(self->size - this->resid);
85 /* this is delibrately redundant code for performance reasons */
89 this->resid = self->uiop->uio_resid;
90 @bytes[pid, execname, self->type, "W"] = sum(self->size - this->resid);
98 printf("%-6s %-16s %6s %4s %9s\n",
99 "PID", "CMD", "VTYPE", "DIR", "BYTES");
100 printa("%-6d %-16s %6s %4s %@9d\n", @bytes);