1N/A# diskhits - disk access by file offset. 1N/A# Written using DTrace (Solaris 10 3/05). 1N/A# $Id: diskhits 3 2007-08-01 10:50:08Z brendan $ 1N/A# This prints how a file was accessed, the locations on a distribution plot. 1N/A# This is for the cache misses only - the file activity that resulted in 1N/A# USAGE: diskhits pathname 1N/A# Location (KB) The file offset of the disk activity, Kbytes. 1N/A# Size (KB) Size of the disk activity, Kbytes. 1N/A# Total RW Total disk activity, reads + writes. 1N/A# iosnoop (DTraceToolkit) 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# 08-Jun-2005 Brendan Gregg Created this. 1N/A# 20-Apr-2006 " " Last update. 1N/A USAGE: diskhits pathname 1N/A diskhits /var/adm/wtmpx 1N/A### Process arguments 1N/Aif (( $# != 1 )); then 1N/Aif [[ $1 == "-h" ]]; then 1N/Aif [[ ! -e $pathname ]]; then 1N/A print "ERROR2: file $pathname not found" >&2 1N/A### Calculate output scale 1N/Aset -- `ls -l $pathname` 1N/A(( file_kb_max = filesize / 1024 )) 1N/A(( scale_kb = filesize / (1024 * report_lines) )) 1N/Aif (( file_kb_max < 20 )); then file_kb_max=20; fi 1N/Aif (( scale_kb < 1 )); then scale_kb=1; fi 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A inline string PATHNAME = "'$pathname'"; 1N/A inline int FILE_KB_MAX = '$file_kb_max'; 1N/A inline int SCALE_KB = '$scale_kb'; 1N/A printf("Tracing... Hit Ctrl-C to end.\n"); 1N/A /args[2]->fi_pathname == PATHNAME/ 1N/A this->kb = args[2]->fi_offset == -1 ? -1 : args[2]->fi_offset / 1024; 1N/A @Location = lquantize(this->kb, 0, FILE_KB_MAX, SCALE_KB); 1N/A @Size = quantize(args[0]->b_bcount/1024); 1N/A @Total = sum(args[0]->b_bcount/1024); 1N/A printf("Location (KB),"); 1N/A printf("Size (KB),"); 1N/A printa("Total RW: %@d KB\n", @Total);