Differences between revisions 6 and 7
Revision 6 as of 2007-08-21 21:17:39
Size: 1358
Editor: FChE
Comment: use aggregate arrays for better parallelism during data collection
Revision 7 as of 2008-01-10 19:47:34
Size: 1360
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 46: Line 46:
This script is based on [http://sourceware.org/systemtap/wiki/HomePage?action=AttachFile&do=get&target=LWESFO06.pdf SystemTap High-level presentation from Linux World San Francisco August 2006] This script is based on [[http://sourceware.org/systemtap/wiki/HomePage?action=AttachFile&do=get&target=LWESFO06.pdf|SystemTap High-level presentation from Linux World San Francisco August 2006]]

iostat for user IDs

Problem

We want to know which UID is doing the most IO on the system.

Scripts

global reads, writes, total_io

probe kernel.function("vfs_read") {
    reads[uid()] <<< $count
}

probe kernel.function("vfs_write") {
    writes[uid()] <<< $count
}

# print top 10 IO processes every 5 seconds
probe timer.s(5) {
    foreach (id in reads)
        total_io[id] += @sum(reads[id])
    foreach (id in writes)
        total_io[id] += @sum(writes[id])

    printf ("%10s\t%10s\t%10s\n", "User ID", "KB Read", "KB Written")

    foreach (id in total_io- limit 10)
        printf("%10d\t%10d\t%10d\n", id,
               @count(reads[id]) ? @sum(reads[id])/1024 : 0, 
               @count(writes[id]) ? @sum(writes[id])/1024 : 0)

    delete reads
    delete writes
    delete total_io

    print("\n")
}

Output

   User ID         KB Read      KB Written
         0           65432               0
     19420           54826               0
        82            4864               0
     65534            4864               0
       501              25              68

This script is based on SystemTap High-level presentation from Linux World San Francisco August 2006

None: Scripts/uid-iotop (last edited 2008-01-10 19:47:34 by localhost)