diff options
Diffstat (limited to 'cddl/contrib/dtracetoolkit/Disk')
-rw-r--r-- | cddl/contrib/dtracetoolkit/Disk/Readme | 3 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/bitesize.d | 81 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/diskhits | 113 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/hotspot.d | 71 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/iofile.d | 79 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/iofileb.d | 59 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/iopending | 261 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Disk/seeksize.d | 85 |
8 files changed, 752 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/Disk/Readme b/cddl/contrib/dtracetoolkit/Disk/Readme new file mode 100644 index 0000000..37a5301 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/Readme @@ -0,0 +1,3 @@ +Disk - Disk based analysis + + These are scripts that analyse I/O activity that has made it to the disks. diff --git a/cddl/contrib/dtracetoolkit/Disk/bitesize.d b/cddl/contrib/dtracetoolkit/Disk/bitesize.d new file mode 100755 index 0000000..f2e8ea4 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/bitesize.d @@ -0,0 +1,81 @@ +#!/usr/sbin/dtrace -s +/* + * bitesize.d - analyse disk I/O size by process. + * Written using DTrace (Solaris 10 3/05). + * + * This produces a report for the size of disk events caused by + * processes. These are the disk events sent by the block I/O driver. + * + * If applications must use the disks, we generally prefer they do so + * with large I/O sizes. + * + * $Id: bitesize.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: bitesize.d # wait several seconds, then hit Ctrl-C + * + * FIELDS: + * PID process ID + * CMD command and argument list + * value size in bytes + * count number of I/O operations + * + * NOTES: + * + * The application may be requesting smaller sized operations, which + * are being rounded up to the nearest sector size or UFS block size. + * To analyse what the application is requesting, DTraceToolkit programs + * such as Proc/fddist may help. + * + * SEE ALSO: seeksize.d, iosnoop + * + * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 31-Mar-2004 Brendan Gregg Created this, build 51. + * 10-Oct-2004 " " Rewrote to use the io provider, build 63. + * 18-Feb-2006 " " Last update. + */ + +#pragma D option quiet + +/* + * Print header + */ +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +/* + * Process io start + */ +io:::start +{ + /* fetch details */ + this->size = args[0]->b_bcount; + + /* store details */ + @Size[pid, curpsinfo->pr_psargs] = quantize(this->size); +} + +/* + * Print final report + */ +dtrace:::END +{ + printf("\n%8s %s\n", "PID", "CMD"); + printa("%8d %S\n%@d\n", @Size); +} diff --git a/cddl/contrib/dtracetoolkit/Disk/diskhits b/cddl/contrib/dtracetoolkit/Disk/diskhits new file mode 100755 index 0000000..3d72e4a --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/diskhits @@ -0,0 +1,113 @@ +#!/usr/bin/ksh +# +# diskhits - disk access by file offset. +# Written using DTrace (Solaris 10 3/05). +# +# $Id: diskhits 3 2007-08-01 10:50:08Z brendan $ +# +# This prints how a file was accessed, the locations on a distribution plot. +# This is for the cache misses only - the file activity that resulted in +# disk events. +# +# USAGE: diskhits pathname +# eg, +# diskhits /var/adm/messages +# +# FIELDS: +# Location (KB) The file offset of the disk activity, Kbytes. +# Size (KB) Size of the disk activity, Kbytes. +# Total RW Total disk activity, reads + writes. +# +# BASED ON: /usr/demo/dtrace/applicat.d +# +# SEE ALSO: DTrace Guide "io Provider" chapter (docs.sun.com) +# iosnoop (DTraceToolkit) +# +# PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at Docs/cddl1.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# CDDL HEADER END +# +# 08-Jun-2005 Brendan Gregg Created this. +# 20-Apr-2006 " " Last update. +# + +### Usage +function usage +{ + cat <<-END >&2 + USAGE: diskhits pathname + eg, + diskhits /var/adm/wtmpx + END + exit 1 +} + +### Process arguments +if (( $# != 1 )); then + usage +fi +if [[ $1 == "-h" ]]; then + usage +fi +pathname=$1 +if [[ ! -e $pathname ]]; then + print "ERROR2: file $pathname not found" >&2 + exit 2 +fi + +### Calculate output scale +report_lines=20 +set -- `ls -l $pathname` +filesize=$5 +(( file_kb_max = filesize / 1024 )) +(( scale_kb = filesize / (1024 * report_lines) )) +if (( file_kb_max < 20 )); then file_kb_max=20; fi +if (( scale_kb < 1 )); then scale_kb=1; fi + +# +# Run DTrace +# +/usr/sbin/dtrace -n ' + #pragma D option quiet + + inline string PATHNAME = "'$pathname'"; + inline int FILE_KB_MAX = '$file_kb_max'; + inline int SCALE_KB = '$scale_kb'; + + dtrace:::BEGIN + { + printf("Tracing... Hit Ctrl-C to end.\n"); + } + + io:::start + /args[2]->fi_pathname == PATHNAME/ + { + this->kb = args[2]->fi_offset == -1 ? -1 : args[2]->fi_offset / 1024; + @Location = lquantize(this->kb, 0, FILE_KB_MAX, SCALE_KB); + @Size = quantize(args[0]->b_bcount/1024); + @Total = sum(args[0]->b_bcount/1024); + } + + dtrace:::END + { + printf("Location (KB),"); + printa(@Location); + + printf("Size (KB),"); + printa(@Size); + + printa("Total RW: %@d KB\n", @Total); + } +' diff --git a/cddl/contrib/dtracetoolkit/Disk/hotspot.d b/cddl/contrib/dtracetoolkit/Disk/hotspot.d new file mode 100755 index 0000000..6ab6ee4 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/hotspot.d @@ -0,0 +1,71 @@ +#!/usr/sbin/dtrace -s +/* + * hotspot.d - plot disk event by location, look for hotspots. + * Written in DTrace (Solaris 10 3/05). + * + * This simple DTrace script determines if disk activity is occuring in + * the one place - a "hotspot". This helps us understand the system's usage + * of a disk, it does not imply that the existance or not of a hotspot is + * good or bad (often may be good, less seeking). + * + * $Id: hotspot.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: hotspot.d # hit Ctrl-C to end + * + * FIELDS: + * Disk disk instance name + * Major driver major number + * Minor driver minor number + * value location, by megabyte + * count number of I/O operations + * + * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 07-May-2005 Brendan Gregg Created this. + * 20-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +inline int DISK_MB_MAX = 1000000; /* max size of a single disk */ +inline int REPORT_SCALE_MB = 1000; /* output step size for report */ + +/* + * Print header + */ +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +/* + * Process disk event + */ +io:::start +{ + this->mb = args[0]->b_blkno / 2048; + @Block[args[1]->dev_statname, args[1]->dev_major, args[1]->dev_minor] = + lquantize(this->mb, 0, DISK_MB_MAX, REPORT_SCALE_MB); +} + +/* + * Print final report + */ +dtrace:::END +{ + printa("Disk: %s Major,Minor: %d,%d\n%@d\n", @Block); +} diff --git a/cddl/contrib/dtracetoolkit/Disk/iofile.d b/cddl/contrib/dtracetoolkit/Disk/iofile.d new file mode 100755 index 0000000..255057a --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/iofile.d @@ -0,0 +1,79 @@ +#!/usr/sbin/dtrace -s +/* + * iofile.d - I/O wait time by filename and process. + * Written using DTrace (Solaris 10 3/05). + * + * This prints the total I/O wait times for each filename by process. + * This can help determine why an application is performing poorly by + * identifying which file they are waiting on, and the total times. + * Both disk and NFS I/O are measured. + * + * $Id: iofile.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: iofile.d # wait, then hit Ctrl-C to end + * + * FIELDS: + * PID Process ID + * CMD Process name + * TIME Total wait time for disk events, us + * FILE File pathname + * + * BASED ON: /usr/demo/dtrace/iocpu.d + * + * SEE ALSO: iosnoop, iotop + * + * PORTIONS: Copyright (c) 2005, 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 24-Jul-2005 Brendan Gregg Created this. + * 20-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +/* print header */ +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +/* save time at start */ +io:::wait-start +{ + self->start = timestamp; +} + +/* process event */ +io:::wait-done +/self->start/ +{ + /* + * wait-done is used as we are measing wait times. It also + * is triggered when the correct thread is on the CPU, obviating + * the need to link process details to the start event. + */ + this->elapsed = timestamp - self->start; + @files[pid, execname, args[2]->fi_pathname] = sum(this->elapsed); + self->start = 0; +} + +/* print report */ +dtrace:::END +{ + normalize(@files, 1000); + printf("%6s %-12s %8s %s\n", "PID", "CMD", "TIME", "FILE"); + printa("%6d %-12.12s %@8d %s\n", @files); +} diff --git a/cddl/contrib/dtracetoolkit/Disk/iofileb.d b/cddl/contrib/dtracetoolkit/Disk/iofileb.d new file mode 100755 index 0000000..e7572f3 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/iofileb.d @@ -0,0 +1,59 @@ +#!/usr/sbin/dtrace -s +/* + * iofileb.d - I/O bytes by filename and process. + * Written using DTrace (Solaris 10 3/05). + * + * This prints a summary of requested disk activity by pathname, + * providing totals of the I/O events in bytes. It is a companion to the + * iofile.d script - which prints in terms of I/O wait time, not bytes. + * I/O wait time is a better metric for understanding performance issues. + * Both disk and NFS I/O are measured. + * + * $Id: iofileb.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: iofileb.d # wait several seconds, then hit Ctrl-C + * + * FIELDS: + * PID process ID + * CMD command name + * KB Kilobytes of disk I/O + * FILE Full pathname of the file + * + * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 20-Feb-2006 Brendan Gregg Created this. + * 20-Feb-2006 " " Last update. + */ + +#pragma D option quiet + +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +io:::start +{ + @files[pid, execname, args[2]->fi_pathname] = sum(args[0]->b_bcount); +} + +dtrace:::END +{ + normalize(@files, 1024); + printf("%6s %-12s %6s %s\n", "PID", "CMD", "KB", "FILE"); + printa("%6d %-12.12s %@6d %s\n", @files); +} diff --git a/cddl/contrib/dtracetoolkit/Disk/iopending b/cddl/contrib/dtracetoolkit/Disk/iopending new file mode 100755 index 0000000..ef9d4da --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/iopending @@ -0,0 +1,261 @@ +#!/usr/bin/ksh +# +# iopending - Print a plot for the number of pending disk I/O events. +# Written using DTrace (Solaris 10 3/05). +# +# This is measuring disk events that have made it past system caches. +# By plotting a distribution graph of the number of pending events, the +# "serialness" or "parallelness" of disk behaviour can be distinguished. +# +# $Id: iopending 3 2007-08-01 10:50:08Z brendan $ +# +# USAGE: iopending [-c] [-d device] [-f filename] +# [-m mount_point] [interval [count]] +# +# -c # clear the screen +# -d device # instance name to snoop (eg, dad0) +# -f filename # full pathname of file to snoop +# -m mount_point # this FS only (will skip raw events) +# eg, +# iopending # default output, 5 second intervals +# iopending 1 # 1 second samples +# iopending -c # clear the screen +# iopending 5 12 # print 12 x 5 second samples +# +# FIELDS: +# value number of pending events, 0 == idle +# count number of samples @ 1000 Hz +# load 1 min load average +# disk_r total disk read Kbytes for sample +# disk_w total disk write Kbytes for sample +# +# SEE ALSO: iosnoop, iotop +# +# IDEA: Dr Rex di Bona (Sydney, Australia) +# +# COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at Docs/cddl1.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# CDDL HEADER END +# +# Author: Brendan Gregg [Sydney, Australia] +# +# 01-Nov-2005 Brendan Gregg Created this. +# 20-Apr-2006 " " Last update. +# + + +############################## +# --- Process Arguments --- +# + +### default variables +opt_device=0; opt_file=0; opt_mount=0; opt_clear=0; +opt_def=1; filter=0; device=.; filename=.; mount=. +interval=5; count=-1 + +### process options +while getopts cd:f:hm: name +do + case $name in + c) opt_clear=1 ;; + d) opt_device=1; device=$OPTARG ;; + f) opt_file=1; filename=$OPTARG ;; + m) opt_mount=1; mount=$OPTARG ;; + h|?) cat <<-END >&2 + USAGE: iopending [-c] [-d device] [-f filename] + [-m mount_point] [interval [count]] + + -c # clear the screen + -d device # instance name to snoop + -f filename # snoop this file only + -m mount_point # this FS only + eg, + iopending # default output, 5 second samples + iopending 1 # 1 second samples + iopending -m / # snoop events on filesystem / only + iopending 5 12 # print 12 x 5 second samples + END + exit 1 + esac +done + +shift $(( $OPTIND - 1 )) + +### option logic +if [[ "$1" > 0 ]]; then + interval=$1; shift +fi +if [[ "$1" > 0 ]]; then + count=$1; shift +fi +if (( opt_device || opt_mount || opt_file )); then + filter=1 +fi +if (( opt_clear )); then + clearstr=`clear` +else + clearstr=. +fi + + + +################################# +# --- Main Program, DTrace --- +# +/usr/sbin/dtrace -n ' + /* + * Command line arguments + */ + inline int OPT_def = '$opt_def'; + inline int OPT_clear = '$opt_clear'; + inline int OPT_device = '$opt_device'; + inline int OPT_mount = '$opt_mount'; + inline int OPT_file = '$opt_file'; + inline int INTERVAL = '$interval'; + inline int COUNTER = '$count'; + inline int FILTER = '$filter'; + inline string DEVICE = "'$device'"; + inline string FILENAME = "'$filename'"; + inline string MOUNT = "'$mount'"; + inline string CLEAR = "'$clearstr'"; + + inline int MAX_PENDING = 32; /* max pending value */ + + #pragma D option quiet + + /* + * Print header + */ + dtrace:::BEGIN + { + /* starting values */ + counts = COUNTER; + secs = INTERVAL; + disk_r = 0; + disk_w = 0; + pending = 0; + + printf("Tracing... Please wait.\n"); + } + + /* + * Check event is being traced + */ + io:genunix::start, + io:genunix::done + { + /* default is to trace unless filtering, */ + this->ok = FILTER ? 0 : 1; + + /* check each filter, */ + (OPT_device == 1 && DEVICE == args[1]->dev_statname)? this->ok = 1 : 1; + (OPT_file == 1 && FILENAME == args[2]->fi_pathname) ? this->ok = 1 : 1; + (OPT_mount == 1 && MOUNT == args[2]->fi_mount) ? this->ok = 1 : 1; + } + + /* + * Store entry details + */ + io:genunix::start + /this->ok/ + { + /* track bytes */ + disk_r += args[0]->b_flags & B_READ ? args[0]->b_bcount : 0; + disk_w += args[0]->b_flags & B_READ ? 0 : args[0]->b_bcount; + + /* increase event pending count */ + pending++; + } + + /* + * Process and Print completion + */ + io:genunix::done + /this->ok/ + { + /* decrease event pending count */ + pending--; + } + + /* + * Prevent pending from underflowing + * this can happen if this program is started during disk events. + */ + io:genunix::done + /pending < 0/ + { + pending = 0; + } + + /* + * Timer + */ + profile:::tick-1sec + { + secs--; + } + + profile:::profile-1000hz + { + @out = lquantize(pending, 0, MAX_PENDING, 1); + } + + /* + * Print Report + */ + profile:::tick-1sec + /secs == 0/ + { + /* fetch 1 min load average */ + this->load1a = `hp_avenrun[0] / 65536; + this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536; + + /* convert counters to Kbytes */ + disk_r /= 1024; + disk_w /= 1024; + + /* print status */ + OPT_clear ? printf("%s", CLEAR) : 1; + printf("%Y, load: %d.%02d, disk_r: %6d KB, disk_w: %6d KB", + walltimestamp, this->load1a, this->load1b, disk_r, disk_w); + + /* print output */ + printa(@out); + + /* clear data */ + trunc(@out); + disk_r = 0; + disk_w = 0; + secs = INTERVAL; + counts--; + } + + /* + * End of program + */ + profile:::tick-1sec + /counts == 0/ + { + exit(0); + } + + /* + * Cleanup for Ctrl-C + */ + dtrace:::END + { + trunc(@out); + } +' diff --git a/cddl/contrib/dtracetoolkit/Disk/seeksize.d b/cddl/contrib/dtracetoolkit/Disk/seeksize.d new file mode 100755 index 0000000..963d9ad --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Disk/seeksize.d @@ -0,0 +1,85 @@ +#!/usr/sbin/dtrace -s +/* + * seeksize.d - analyse disk head seek distance by process. + * Written using DTrace (Solaris 10 3/05). + * + * Disk I/O events caused by processes will in turn cause the disk heads + * to seek. This program analyses those seeks, so that we can determine + * if processes are causing the disks to seek in a "random" or "sequential" + * manner. + * + * $Id: seeksize.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: seeksize.d # wait several seconds, then hit Ctrl-C + * + * FIELDS: + * PID process ID + * CMD command and argument list + * value distance in disk blocks (sectors) + * count number of I/O operations + * + * SEE ALSO: bitesize.d, iosnoop + * + * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 11-Sep-2004 Brendan Gregg Created this. + * 10-Oct-2004 " " Rewrote to use the io provider. + * 20-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +/* + * Print header + */ +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +self int last[dev_t]; + +/* + * Process io start + */ +io:genunix::start +/self->last[args[0]->b_edev] != 0/ +{ + /* calculate seek distance */ + this->last = self->last[args[0]->b_edev]; + this->dist = (int)(args[0]->b_blkno - this->last) > 0 ? + args[0]->b_blkno - this->last : this->last - args[0]->b_blkno; + + /* store details */ + @Size[pid, curpsinfo->pr_psargs] = quantize(this->dist); +} + +io:genunix::start +{ + /* save last position of disk head */ + self->last[args[0]->b_edev] = args[0]->b_blkno + + args[0]->b_bcount / 512; +} + +/* + * Print final report + */ +dtrace:::END +{ + printf("\n%8s %s\n", "PID", "CMD"); + printa("%8d %S\n%@d\n", @Size); +} |