Changeset View
Changeset View
Standalone View
Standalone View
cddl/usr.sbin/dwatch/libexec/io
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
# -*- tab-width: 4 -*- ;; Emacs | |||||
# vi: set filetype=sh tabstop=8 shiftwidth=8 noexpandtab :: Vi/ViM | |||||
############################################################ IDENT(1) | |||||
# | |||||
# $Title: dwatch(8) module for dtrace_io(4) $ | |||||
# $Copyright: 2014-2018 Devin Teske. All rights reserved. $ | |||||
# $FreeBSD$ | |||||
# | |||||
############################################################ DESCRIPTION | |||||
# | |||||
# Display activity related to disk I/O | |||||
# | |||||
############################################################ PROBE | |||||
case "$PROFILE" in | |||||
io) : ${PROBE:=io:::start, io:::done} ;; | |||||
*) : ${PROBE:=io:::${PROFILE#io-}} | |||||
esac | |||||
############################################################ ACTIONS | |||||
exec 9<<EOF | |||||
enum bio_cmd { | |||||
BIO_READ = 0x1, | |||||
BIO_WRITE, | |||||
BIO_DELETE, | |||||
BIO_GETATTR, | |||||
BIO_FLUSH, | |||||
BIO_CMD0, | |||||
BIO_CMD1, | |||||
BIO_CMD2, | |||||
BIO_ZONE | |||||
}; | |||||
enum bio_flags { | |||||
BIO_ERROR = 0x1, | |||||
BIO_DONE, | |||||
BIO_ONQUEUE = 0x4 | |||||
}; | |||||
enum device_type { | |||||
DEVSTAT_TYPE_DIRECT = 0x000, | |||||
DEVSTAT_TYPE_SEQUENTIAL = 0x001, | |||||
DEVSTAT_TYPE_PRINTER = 0x002, | |||||
DEVSTAT_TYPE_PROCESSOR = 0x003, | |||||
DEVSTAT_TYPE_WORM = 0x004, | |||||
DEVSTAT_TYPE_CDROM = 0x005, | |||||
DEVSTAT_TYPE_SCANNER = 0x006, | |||||
DEVSTAT_TYPE_OPTICAL = 0x007, | |||||
DEVSTAT_TYPE_CHANGER = 0x008, | |||||
DEVSTAT_TYPE_COMM = 0x00a, | |||||
DEVSTAT_TYPE_ASC0 = 0x00b, | |||||
DEVSTAT_TYPE_ASC1 = 0x00c, | |||||
DEVSTAT_TYPE_STORARRAY = 0x00d, | |||||
DEVSTAT_TYPE_ENCLOSURE = 0x00e, | |||||
DEVSTAT_TYPE_FLOPPY = 0x00f, | |||||
DEVSTAT_TYPE_MASK = 0x00f, | |||||
DEVSTAT_TYPE_IF_SCSI = 0x010, | |||||
DEVSTAT_TYPE_IF_IDE = 0x020, | |||||
DEVSTAT_TYPE_IF_OTHER = 0x030, | |||||
DEVSTAT_TYPE_IF_MASK = 0x0f0, | |||||
DEVSTAT_TYPE_PASS = 0x100 | |||||
}; | |||||
$PROBE /* probe ID $ID */ | |||||
{${TRACE:+ | |||||
printf("<$ID>"); | |||||
} | |||||
/* | |||||
* Which function triggered? | |||||
*/ | |||||
this->start = probename == "start" ? 1 : 0; | |||||
/* | |||||
* I/O | |||||
*/ | |||||
this->devtype = args[1]->device_type & DEVSTAT_TYPE_MASK; | |||||
this->device_type = this->devtype == DEVSTAT_TYPE_DIRECT ? "DIRECT" : | |||||
(this->devtype == DEVSTAT_TYPE_SEQUENTIAL ? "SEQUENTIAL" : | |||||
(this->devtype == DEVSTAT_TYPE_PRINTER ? "PRINTER" : | |||||
(this->devtype == DEVSTAT_TYPE_PROCESSOR ? "PROCESSOR" : | |||||
(this->devtype == DEVSTAT_TYPE_WORM ? "WORM" : | |||||
(this->devtype == DEVSTAT_TYPE_CDROM ? "CDROM" : | |||||
(this->devtype == DEVSTAT_TYPE_SCANNER ? "SCANNER" : | |||||
(this->devtype == DEVSTAT_TYPE_OPTICAL ? "OPTICAL" : | |||||
(this->devtype == DEVSTAT_TYPE_CHANGER ? "CHANGER" : | |||||
(this->devtype == DEVSTAT_TYPE_COMM ? "COMM" : | |||||
(this->devtype == DEVSTAT_TYPE_ASC0 ? "ASC0" : | |||||
(this->devtype == DEVSTAT_TYPE_ASC1 ? "ASC1" : | |||||
(this->devtype == DEVSTAT_TYPE_STORARRAY ? "STORARRAY" : | |||||
(this->devtype == DEVSTAT_TYPE_ENCLOSURE ? "ENCLOSURE" : | |||||
(this->devtype == DEVSTAT_TYPE_FLOPPY ? "FLOPPY" : | |||||
"UNKNOWN")))))))))))))); | |||||
this->iftype = args[1]->device_type & DEVSTAT_TYPE_IF_MASK; | |||||
this->device_if = this->iftype == DEVSTAT_TYPE_IF_SCSI ? "SCSI" : | |||||
(this->iftype == DEVSTAT_TYPE_IF_IDE ? "IDE" : | |||||
(this->iftype == DEVSTAT_TYPE_IF_OTHER ? "OTHER" : | |||||
"ACCESS")); | |||||
this->device_name = stringof(args[1]->device_name); | |||||
this->unit_number = args[1]->unit_number; | |||||
this->flow = this->start ? "->" : "<-"; | |||||
this->bio_cmd = args[0]->bio_cmd == BIO_READ ? "READ" : | |||||
(args[0]->bio_cmd == BIO_WRITE ? "WRITE" : | |||||
(args[0]->bio_cmd == BIO_DELETE ? "DELETE" : | |||||
(args[0]->bio_cmd == BIO_GETATTR ? "GETATTR" : | |||||
(args[0]->bio_cmd == BIO_FLUSH ? "FLUSH" : | |||||
(args[0]->bio_cmd == BIO_CMD0 ? "CMD0" : | |||||
(args[0]->bio_cmd == BIO_CMD1 ? "CMD1" : | |||||
(args[0]->bio_cmd == BIO_CMD2 ? "CMD2" : | |||||
(args[0]->bio_cmd == BIO_ZONE ? "ZONE" : | |||||
"NA")))))))); | |||||
this->bio_flags = args[0]->bio_flags == BIO_ERROR ? "ERROR" : | |||||
(args[0]->bio_flags == BIO_DONE ? "DONE" : | |||||
(args[0]->bio_flags == BIO_ONQUEUE ? "ONQUEUE" : | |||||
"OK")); | |||||
this->bio_error = args[0]->bio_error; | |||||
this->bio_completed = args[0]->bio_completed; | |||||
} | |||||
EOF | |||||
ACTIONS=$( cat <&9 ) | |||||
ID=$(( $ID + 1 )) | |||||
############################################################ EVENT DETAILS | |||||
exec 9<<EOF | |||||
/* | |||||
* Print I/O details | |||||
*/ | |||||
printf("%s %s %s%d %s %s %s %d byte%s", | |||||
this->device_type, | |||||
this->device_if, | |||||
this->device_name, | |||||
this->unit_number, | |||||
this->flow, | |||||
this->bio_cmd, | |||||
this->bio_flags, | |||||
this->bio_completed, | |||||
this->bio_completed == 1 ? "" : "s"); | |||||
EOF | |||||
EVENT_DETAILS=$( cat <&9 ) | |||||
################################################################################ | |||||
# END | |||||
################################################################################ |