Skip to content

Instantly share code, notes, and snippets.

@szaydel
Last active September 5, 2022 13:22
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/4aa0fa6e8f837f636d16df78ba99aa08 to your computer and use it in GitHub Desktop.
Save szaydel/4aa0fa6e8f837f636d16df78ba99aa08 to your computer and use it in GitHub Desktop.
Script enables monitoring of the TUR commands, their latency and errors returned from the calls.
#!/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)
::sd_send_scsi_TEST_UNIT_READY:entry {
self->un = args[0]->ssc_un;
self->start = timestamp;
}
::sd_send_scsi_TEST_UNIT_READY:return /self->un/ {
@ts[DEV_INST(self->un)] = quantize(timestamp - self->start);
@[DEV_INST(self->un), args[1]] = count();
}
tick-5sec {
printa("device=sd%d err=%d %@d\n", @);
trunc(@);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment