Created
September 3, 2016 23:33
-
-
Save inferiorhumanorgans/625393d66e17803633b7997264b48740 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/sbin/dtrace -s | |
#pragma D option quiet | |
io:::start | |
{ | |
self->ok = 0; | |
/* https://lists.freebsd.org/pipermail/freebsd-dtrace/2015-February/000347.html */ | |
self->ok = (args[0] != NULL) ? 1 : 0; | |
} | |
io:::start | |
/self->ok && (args[0]->bio_cmd & 0x01)/ /* Read */ | |
{ | |
@read_bytes[$$1, strjoin(args[1]->device_name, lltostr(args[1]->unit_number))] = sum(args[0]->bio_bcount); | |
@write_bytes[$$1, strjoin(args[1]->device_name, lltostr(args[1]->unit_number))] = sum(0); | |
@time[$$1, strjoin(args[1]->device_name, lltostr(args[1]->unit_number))] = max(walltimestamp / 1000000000); | |
} | |
io:::start | |
/self->ok && (args[0]->bio_cmd & 0x02)/ /* Write */ | |
{ | |
@read_bytes[$$1, strjoin(args[1]->device_name, lltostr(args[1]->unit_number))] = sum(0); | |
@write_bytes[$$1, strjoin(args[1]->device_name, lltostr(args[1]->unit_number))] = sum(args[0]->bio_bcount); | |
@time[$$1, strjoin(args[1]->device_name, lltostr(args[1]->unit_number))] = max(walltimestamp / 1000000000); | |
} | |
BEGIN, | |
END, | |
tick-$2s | |
{ | |
printa("PUTVAL %s/disk-%s/disk_octets-dtrace %@d:%@d:%@d\n", @time, @read_bytes, @write_bytes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment