Skip to content

Commit

Permalink
add a basic DTrace distribution plot formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jclulow committed Jan 31, 2013
1 parent 2a243e5 commit f853910
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions formatters/dtrace_agg
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/ksh
#
# DTrace Distribution Formatter
#
# This formatter reads and restructures periodic output from a DTrace
# script which is, itself, written to output a distribution plot from
# one of the *quantize() aggregation functions.
#
# Below is a slight modification of a script by Brendan Gregg
# (iolatency.d) which prints the latency of all I/O operations
# once a second. Note that it prints no other output, except for
# a "===" separator line after each second has passed.
#
# Use it with heapmap in log-linear mode, like so:
#
# ./iolatency.d | ./formatters/dtrace_agg | ./heatmap -L
#
#---------------------------------------------------------------------
# #!/usr/sbin/dtrace -qs
#
# io:::start
# {
# start[arg0] = timestamp;
# }
#
# io:::done
# /start[arg0]/
# {
# this->microseconds = (timestamp - start[arg0]) / 1000;
# time = llquantize(this->microseconds, 10, 2, 8, 100);
# start[arg0] = 0;
# }
#
# tick-1s
# {
# printa("%@d\n", @time);
# printf("===\n");
# trunc(@time);
# }
#---------------------------------------------------------------------
#

while read line; do
set -- $line

#
# End of Record:
#
if [[ $1 == "===" ]]; then
echo $record
record=
continue
fi

#
# Skip Header/Blank Rows:
#
if [[ $1 == "" || $3 == "Distribution" ]]; then
continue
fi

#
# Process a bucket row:
#
if [[ $1 == ">=" ]]; then
bkt=$2
count=$4
elif [[ $1 == "<" ]]; then
bkt=0
count=$4
else
bkt=$1
count=$3
fi

if (( count > 0 )); then
record="$record ${bkt}*${count} "
fi
done

0 comments on commit f853910

Please sign in to comment.