1N/A# fddist - file descriptor usage distributions. 1N/A# Written using DTrace (Solaris 10 3/05). 1N/A# This prints distributions for read and write events by file descriptor, 1N/A# by process. This can be used to determine which file descriptor a 1N/A# process is doing the most I/O with. 1N/A# $Id: fddist 3 2007-08-01 10:50:08Z brendan $ 1N/A# USAGE: fddist [-r|-w] # hit Ctrl-C to end sample 1N/A# value file descriptor 1N/A# count number of events 1N/A# PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg. 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# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# 09-Jun-2005 Brendan Gregg Created this. 1N/A# 20-Apr-2006 " " Last update. 1N/A############################## 1N/A# --- Process Arguments --- 1N/A### Default variables 1N/A USAGE: fddist [-r|-w] 1N/A fddist # default, r+w counts 1N/A fddist -r # read count only 1N/Ashift `expr $OPTIND - 1` 1N/Aif [ $opt_read -eq 0 -a $opt_write -eq 0 ]; then 1N/A opt_read=1; opt_write=1 1N/A################################# 1N/A# --- Main Program, DTrace --- 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A inline int OPT_read = '$opt_read'; 1N/A inline int OPT_write = '$opt_write'; 1N/A inline int FDMAX = 255; 1N/A OPT_read && OPT_write ? printf("reads and writes") : 1; 1N/A OPT_read && ! OPT_write ? printf("reads") : 1; 1N/A ! OPT_read && OPT_write ? printf("writes") : 1; 1N/A printf("... Hit Ctrl-C to end.\n"); 1N/A syscall::*read*:entry 1N/A @Count[execname, pid] = lquantize(arg0, 0, FDMAX, 1); 1N/A syscall::*write*:entry 1N/A @Count[execname, pid] = lquantize(arg0, 0, FDMAX, 1); 1N/A printa("EXEC: %-16s PID: %d\n%@d\n",@Count);