# Summarizing Disk Read/Write Traffic

NO ENTRY IN WAR STORIES: Summarize Disk Read/Write Traffic http://sourceware.org/systemtap/examples/io/disktop.stp

This section describes how to identify which processes are performing the heaviest disk reads/writes to the system.

disktop.stp

outputs the top ten processes responsible for the heaviest reads/writes to disk. displays a sample output for this script, and includes the following data per listed process:

- `UID` — user ID. A user ID of `0` refers to the root user.

- `PID` — the ID of the listed process.

- `PPID` — the process ID of the listed process's parent process.

- `CMD` — the name of the listed process.

- `DEVICE` — which storage device the listed process is reading from or writing to.

- `T` — the type of action performed by the listed process; `W` refers to write, while `R` refers to read.

- `BYTES` — the amount of data read to or written from disk.

The time and date in the output of is returned by the functions `ctime()` and `gettimeofday_s()`. `ctime()` derives calendar time in terms of seconds passed since the Unix epoch (January 1, 1970). `gettimeofday_s()` counts the actual number of seconds since Unix epoch, which gives a fairly accurate human-readable timestamp for the output.

In this script, the `$return` is a local variable that stores the actual number of bytes each process reads or writes from the virtual file system. `$return` can only be used in return probes (for example, `vfs.read.return` and `vfs.read.return`).

Sample Output

    [...]
    Mon Sep 29 03:38:28 2008 , Average:  19Kb/sec, Read: 7Kb, Write: 89Kb

    UID      PID     PPID                       CMD   DEVICE    T    BYTES
    0    26319    26294                   firefox     sda5    W        90229
    0     2758     2757           pam_timestamp_c     sda5    R         8064
    0     2885        1                     cupsd     sda5    W         1678

    Mon Sep 29 03:38:38 2008 , Average:   1Kb/sec, Read: 7Kb, Write: 1Kb

    UID      PID     PPID                       CMD   DEVICE    T    BYTES
    0     2758     2757           pam_timestamp_c     sda5    R         8064
    0     2885        1                     cupsd     sda5    W         1678

script examples summarizing disk I/O traffic
examples of SystemTap scripts summarizing disk I/O traffic
summarizing disk I/O traffic script examples
disk I/O traffic, summarizing script examples
I/O traffic, summarizing script examples
heaviest disk reads/writes, identifying script examples
summarizing disk I/O traffic script examples
identifying heaviest disk reads/writes script examples
script examples ctime(), example of usage
examples of SystemTap scripts ctime(), example of usage
ctime(), example of usage script examples
local variables sample usage $return
variables (local) sample usage $return
$return sample usage local variables