# I/O Monitoring (By Device)

This section describes how to monitor I/O activity on a specific device.

## traceio2.stp

traceio2 takes 1 argument: the whole device number. To get this number, use `stat -c "0x%D" `directory``, where ``directory`` is located in the device to be monitored.

The `usrdev2kerndev()` function converts the whole device number into the format understood by the kernel. The output produced by `usrdev2kerndev()` is used in conjunction with the `MKDEV()`, `MINOR()`, and `MAJOR()` functions to determine the major and minor numbers of a specific device.

The output of traceio2 includes the name and ID of any process performing a read/write, the function it is performing (that is, `vfs_read` or `vfs_write`), and the kernel device number.

The following example is an excerpt from the full output of `stap traceio2.stp 0x805`, where `0x805` is the whole device number of `/home`. `/home` resides in `/dev/sda5`, which is the device we wish to monitor.

## traceio2 Sample Output

    [...]
    synergyc(3722) vfs_read 0x800005
    synergyc(3722) vfs_read 0x800005
    cupsd(2889) vfs_write 0x800005
    cupsd(2889) vfs_write 0x800005
    cupsd(2889) vfs_write 0x800005
    [...]