# Making Sense of SCSI Sense

To make sense of SCSI sense I created a knowledge base article on that Understanding SCSI Sense Decoding, in addition I create a web-app to quickly decode the SCSI sense buffer.

One last piece is to actually get the SCSI sense buffer, if you are using Linux you can get it with SystemTap with this STP script:

    probe module("scsi_mod").function("scsi_command_normalize_sense") {
printf("CDB:");
for (i = 0; i < $cmd->cmd_len; i++) { printf(" %02X",$cmd->cmnd[i]);
}
printf(" | SENSE:");
for (i = 0; i < 32; i++) {
printf(" %02X", \$cmd->sense_buffer[i]);
}
printf("\n");
}


The command to run it is as simple as:

stap scsi_sense.stp


This will output something like:

CDB: 4D 00 40 00 00 00 00 00 04 00 | SENSE: 70 00 05 00 00 00 00 0A 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
CDB: 4D 00 40 00 00 00 00 00 04 00 | SENSE: 70 00 05 00 00 00 00 0A 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
CDB: A1 08 2E 00 01 00 00 00 00 EC 00 00 | SENSE: 72 01 00 1D 00 00 00 0E 09 0C 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00
CDB: A1 08 2E 00 01 00 00 00 00 EC 00 00 | SENSE: 72 01 00 1D 00 00 00 0E 09 0C 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00
CDB: 85 08 2E 00 00 00 01 00 00 00 00 00 00 00 EC 00 | SENSE: 72 01 00 1D 00 00 00 0E 09 0C 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00
CDB: 85 08 2E 00 00 00 01 00 00 00 00 00 00 00 EC 00 | SENSE: 72 01 00 1D 00 00 00 0E 09 0C 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00
CDB: 85 08 2E 00 00 00 01 00 00 00 00 00 00 00 EC 00 | SENSE: 72 01 00 1D 00 00 00 0E 09 0C 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00
CDB: 85 08 2E 00 00 00 01 00 00 00 00 00 00 00 EC 00 | SENSE: 72 01 00 1D 00 00 00 0E 09 0C 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00


This shows for each eror the CDB of the command and the sense buffer. It looks like it shows each case twice since the Linux kernel calls the scsi_command_normalize_sense twice for each error but that’s a small pain.