srpsnoop.d
Snoops Local Events on a Server
This simple script snoops srp
events when run on a srp
target server.
#!/usr/sbin/dtrace -s #pragma D option quiet #pragma D option switchrate=10 dtrace:::BEGIN { printf("%17s %3s %-40s %-14s %6s %10s %6s\n", "TIMESTAMP", "CPU", "REMOTE GID", "EVENT", "BYTES", "TAG", "SCSIOP"); /* * SCSI opcode to string translation hash. This is from * /usrp/include/sys/scsi/generic/commands.h. If you would * rather all hex, comment this out. */ scsiop[0x08] = "read"; scsiop[0x0a] = "write"; scsiop[0x0b] = "seek"; scsiop[0x28] = "read(10)"; scsiop[0x2a] = "write(10)"; scsiop[0x2b] = "seek(10)"; } srp:::login-* { printf("%17d %3d %-40s %-14s %17d -\n", timestamp, cpu, args[0]->ci_remote, probename, args[2]->li_task_tag); } srp:::task-command, srp:::task-response, srp:::scsi-response { printf("%17d %3d %-40s %-14s %6d %10d -\n", timestamp, cpu, args[0]->ci_remote, probename, 0, args[2]->ti_task_tag); } srp:::scsi-command /scsiop[args[2]->ic_cdb[0]] != NULL/ { printf("%17d %3d %-40s %-14s %6d %10d %s\n", timestamp, cpu, args[0]->ci_remote, probename, 0, args[3]->ti_task_tag, scsiop[args[2]->ic_cdb[0]]); } srp:::scsi-command /scsiop[args[2]->ic_cdb[0]] == NULL/ { printf("%17d %3d %-40s %-14s %6d %10d 0x%x\n", timestamp, cpu, args[0]->ci_remote, probename, 0, args[3]->ti_task_tag, args[2]->ic_cdb[0]); } srp:::xfer-start, srp:::xfer-done { printf("%17d %3d %-40s %-14s %6d %10d %s\n", timestamp, cpu, args[0]->ci_remote, probename,args[2]->xfer_len, args[3]->ti_task_tag, args[2]->xfer_type > 0 ? "READ" : "WRITE"); }
This output shows the snoop on dd
commands executed by the initiator.
# dtrace -s ./srpsnoop.d
TIMESTAMP CPU REMOTE GID EVENT BYTES TAG SCSIOP
22644410404019 3 fe80000000000000:0003ba0001004d31 task-command 0 26 -
22644410493068 3 fe80000000000000:0003ba0001004d31 scsi-command 0 26 read(10)
22644410511422 3 fe80000000000000:0003ba0001004d31 task-command 0 30 -
22644410541494 3 fe80000000000000:0003ba0001004d31 scsi-command 0 30 read(10)
22644410621049 0 fe80000000000000:0003ba0001004d31 xfer-start 2048 26 READ
22644410720486 1 fe80000000000000:0003ba0001004d31 xfer-start 49152 30 READ
22644410681390 3 fe80000000000000:0003ba0001004d31 xfer-done 2048 26 READ
22644410694719 3 fe80000000000000:0003ba0001004d31 scsi-response 0 26 -
22644410703358 3 fe80000000000000:0003ba0001004d31 task-response 0 26 -
22644410895424 3 fe80000000000000:0003ba0001004d31 xfer-done 49152 30 READ
22644410901576 3 fe80000000000000:0003ba0001004d31 scsi-response 0 30 -
22644410905717 3 fe80000000000000:0003ba0001004d31 task-response 0 30 -
22727363721107 3 fe80000000000000:0003ba0001004d31 task-command 0 59 -
22727363919179 0 fe80000000000000:0003ba0001004d31 xfer-start 10240 59 WRITE
22727364095164 0 fe80000000000000:0003ba0001004d31 scsi-response 0 59 -
22727364105406 0 fe80000000000000:0003ba0001004d31 task-response 0 59 -
22727363812953 3 fe80000000000000:0003ba0001004d31 scsi-command 0 59 write(10)
22727363986185 3 fe80000000000000:0003ba0001004d31 xfer-done 10240 59 WRITE
The following table describes the output fields.
Field | Description |
---|---|
|
CPU event occurred on |
|
GID of the client HCA port |
|
srp event type |
|
Data bytes |
|
Initiator task tag |
|
SCSI opcode as a description, as hex, or '-' |