Skip to content

Instantly share code, notes, and snippets.

@szaydel
Created September 5, 2022 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szaydel/1386f3f4e182bb54d3fa5105fd24a749 to your computer and use it in GitHub Desktop.
Save szaydel/1386f3f4e182bb54d3fa5105fd24a749 to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -Cs
#pragma D option quiet
#define SD_TO_DEVINFO(un) ((struct dev_info *)((un)->un_sd->sd_dev))
#define DEV_NAME(un) \
stringof(`devnamesp[SD_TO_DEVINFO(un)->devi_major].dn_name) /* ` */
#define DEV_INST(un) (SD_TO_DEVINFO(un)->devi_instance)
#define SD_GET_XBUF(bp) ((struct sd_xbuf *)((bp)->b_private))
#define SD_GET_UN(bp) ((SD_GET_XBUF(bp))->xb_un)
#define DEVI_ADDR(un) (SD_TO_DEVINFO(un)->devi_addr_buf)
:sd:sdstrategy:entry {
start[args[0]] = timestamp;
}
:sd:sd_buf_iodone:entry /start[args[2]] != 0/ {
this->un = SD_GET_UN(args[2]);
this->devname = DEV_NAME(this->un);
this->inst = DEV_INST(this->un);
this->name = DEVI_ADDR(this->un);
/* skip over the leading 'g' character */
if (this->name[0] == 'g') {
this->name++;
}
@[(string)this->name, this->devname, this->inst] \
= quantize(timestamp - start[args[2]]);
start[args[2]] = 0;
}
tick-5sec {
printa("\t%s / (%s%d) %@d\n", @); trunc(@);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment