# I/O Monitoring (By Device)

example from http://sourceware.org/systemtap/examples/io/traceio2.stp, but error WAR STORY: http://sourceware.org/systemtap/wiki/WSDeviceMonitor?highlight=((WarStories)), but script errored was able to correct script through http://sourceware.org/systemtap/wiki/WSFileMonitor?highlight=((WarStories))

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

traceio2.stp

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 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.

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
    [...]

script examples monitoring device I/O
examples of SystemTap scripts monitoring device I/O
monitoring device I/O examples of SystemTap scripts
I/O monitoring (by device) examples of SystemTap scripts
device I/O, monitoring examples of SystemTap scripts
script examples stat -c, determining whole device number
examples of SystemTap scripts stat -c, determining whole device number
stat -c, determining whole device number examples of SystemTap scripts
script examples whole device number (usage as a command-line argument)
examples of SystemTap scripts whole device number (usage as a command-line argument)
whole device number (usage as a command-line argument) examples of SystemTap scripts
script examples usrdev2kerndev()
examples of SystemTap scripts usrdev2kerndev()
usrdev2kerndev() examples of SystemTap scripts