1N/A#!/usr/sbin/dtrace -s
1N/A/*
1N/A * seeksize.d - analyse disk head seek distance by process.
1N/A * Written using DTrace (Solaris 10 3/05).
1N/A *
1N/A * Disk I/O events caused by processes will in turn cause the disk heads
1N/A * to seek. This program analyses those seeks, so that we can determine
1N/A * if processes are causing the disks to seek in a "random" or "sequential"
1N/A * manner.
1N/A *
1N/A * $Id: seeksize.d 3 2007-08-01 10:50:08Z brendan $
1N/A *
1N/A * USAGE: seeksize.d # wait several seconds, then hit Ctrl-C
1N/A *
1N/A * FIELDS:
1N/A * PID process ID
1N/A * CMD command and argument list
1N/A * value distance in disk blocks (sectors)
1N/A * count number of I/O operations
1N/A *
1N/A * SEE ALSO: bitesize.d, iosnoop
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 * 11-Sep-2004 Brendan Gregg Created this.
1N/A * 10-Oct-2004 " " Rewrote to use the io provider.
1N/A * 20-Apr-2006 " " Last update.
1N/A */
1N/A
1N/A#pragma D option quiet
1N/A
1N/A/*
1N/A * Print header
1N/A */
1N/Adtrace:::BEGIN
1N/A{
1N/A printf("Tracing... Hit Ctrl-C to end.\n");
1N/A}
1N/A
1N/Aself int last[dev_t];
1N/A
1N/A/*
1N/A * Process io start
1N/A */
1N/Aio:genunix::start
1N/A/self->last[args[0]->b_edev] != 0/
1N/A{
1N/A /* calculate seek distance */
1N/A this->last = self->last[args[0]->b_edev];
1N/A this->dist = (int)(args[0]->b_blkno - this->last) > 0 ?
1N/A args[0]->b_blkno - this->last : this->last - args[0]->b_blkno;
1N/A
1N/A /* store details */
1N/A @Size[pid, curpsinfo->pr_psargs] = quantize(this->dist);
1N/A}
1N/A
1N/Aio:genunix::start
1N/A{
1N/A /* save last position of disk head */
1N/A self->last[args[0]->b_edev] = args[0]->b_blkno +
1N/A args[0]->b_bcount / 512;
1N/A}
1N/A
1N/A/*
1N/A * Print final report
1N/A */
1N/Adtrace:::END
1N/A{
1N/A printf("\n%8s %s\n", "PID", "CMD");
1N/A printa("%8d %S\n%@d\n", @Size);
1N/A}