-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a basic DTrace distribution plot formatter
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |