Created
October 17, 2022 13:53
-
-
Save szaydel/ffa7ef10ec59170c5576eb6f52cd260c to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
runtime=60 | |
interval=10 | |
while getopts i:t: name; do | |
case $name in | |
i) interval="$OPTARG";; | |
t) runtime="$OPTARG";; | |
?) printf "Usage: %s: [-i <value>] [-t <value>]\n" "$0" | |
exit 2;; | |
esac | |
done | |
dtrace -qn ' | |
BEGIN { | |
probefunc_to_op["zfs_tdm_read"] = "R remote"; | |
probefunc_to_op["zfs_tdm_write"] = "W remote"; | |
probefunc_to_op["zfs_read"] = "R local"; | |
probefunc_to_op["zfs_write"] = "W local"; | |
} | |
::zfs_tdm_read:entry,::zfs_tdm_write:entry, | |
::zfs_read:entry,::zfs_write:entry { | |
if (args[0]->v_path != NULL) { | |
this->p = strstr(args[0]->v_path, "/storage"); | |
if (this->p != "") { | |
self->args0 = args[0]; | |
self->resid = args[1]->uio_resid; | |
} | |
} | |
} | |
::zfs_tdm_read:return,::zfs_tdm_write:return, | |
::zfs_read:return,::zfs_write:return /self->args0/ { | |
this->vnodep = self->args0; | |
this->p = this->vnodep->v_path != 0 ? | |
cleanpath(this->vnodep->v_path): "\_(ツ)_/¯"; | |
@ct[probefunc_to_op[probefunc], this->p] = count(); | |
@av_iosz[probefunc_to_op[probefunc], this->p] = avg(self->resid); | |
@min_iosz[probefunc_to_op[probefunc], this->p] = min(self->resid); | |
@max_iosz[probefunc_to_op[probefunc], this->p] = max(self->resid); | |
@xferred[probefunc_to_op[probefunc], this->p] = sum(self->resid); | |
@bytes[probefunc_to_op[probefunc]] = sum(self->resid); | |
@reqsz[probefunc_to_op[probefunc]] = quantize(self->resid); | |
self->args0 = 0; | |
self->resid = 0; | |
} | |
tick-$1sec { /* this is the -i parameter */ | |
normalize(@xferred, 1024); | |
printf("%Y\n--------------------\n", walltimestamp); | |
printa("%s %s\t count=%@d\tav_iosz=%@d\tmin_iosz=%@d\tmax_iosz=%@d\txferred(KB)=%@d\n", @ct, @av_iosz, @min_iosz, @max_iosz, @xferred); | |
printf("---\n"); | |
trunc(@ct); trunc(@av_iosz); trunc(@min_iosz); | |
trunc(@max_iosz); trunc(@xferred); | |
} | |
tick-$2sec { /* this is the -t parameter */ | |
printf("\n=== Summary ===\n"); | |
normalize(@bytes, 1024*1024); | |
printa("IO size (%s): %@d\n", @reqsz); | |
printa("total (%s): %@dMB\n", @bytes); | |
exit(0); | |
}' "$interval" "$runtime" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment