/usr/share/systemtap/examples/io
NameSizeModeActions
capture_ssl_master_secrets.meta6640644editdlrm
capture_ssl_master_secrets.stp10900755editdlrm
capture_ssl_master_secrets.txt19070644editdlrm
deviceseeks.meta4900644editdlrm
deviceseeks.stp12920755editdlrm
deviceseeks.txt53950644editdlrm
disktop.meta3810644editdlrm
disktop.stp17940755editdlrm
eatmydata.meta3370644editdlrm
eatmydata.stp11880755editdlrm
eatmydata.txt3040644editdlrm
enospc.meta3320644editdlrm
enospc.stp23180755editdlrm
inodewatch.meta4750644editdlrm
inodewatch.stp2450755editdlrm
inodewatch2.meta5040644editdlrm
inodewatch2.stp3900755editdlrm
ioblktime.meta7690644editdlrm
ioblktime.stp7880755editdlrm
iodevstats.meta7380644editdlrm
iodevstats.stp11520755editdlrm
iodevstats.txt5280644editdlrm
iostat-scsi.meta6080644editdlrm
iostat-scsi.stp43660755editdlrm
iostat-scsi.txt4810644editdlrm
iostats.meta6710644editdlrm
iostats.stp11540755editdlrm
iostats.txt3610644editdlrm
iotime.meta10240644editdlrm
iotime.stp28930755editdlrm
iotop.meta4100644editdlrm
iotop.stp6240755editdlrm
io_submit.meta5080644editdlrm
io_submit.stp19060755editdlrm
io_submit.tcl1400644editdlrm
mbrwatch.meta5590644editdlrm
mbrwatch.stp2340755editdlrm
mbrwatch.tcl1400644editdlrm
mbrwatch.txt7880644editdlrm
nfs_func_users.meta6650644editdlrm
nfs_func_users.stp3410755editdlrm
slowvfs.meta4260644editdlrm
slowvfs.stp2810755editdlrm
switchfile.meta3300644editdlrm
switchfile.stp2310644editdlrm
traceaio.c26240644editdlrm
traceaio.meta3310644editdlrm
traceaio.stp18250755editdlrm
traceaio.txt27610644editdlrm
traceio.meta4030644editdlrm
traceio.stp13840755editdlrm
traceio2.meta4000644editdlrm
traceio2.stp4940755editdlrm
ttyspy.meta5210644editdlrm
ttyspy.stp17500755editdlrm
ttyspy.txt4550644editdlrm
Edit: /usr/share/systemtap/examples/io/iotime.stp (2893B)
#!/usr/bin/stap /* * Copyright (C) 2006-2018 Red Hat Inc. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Print out the amount of time spent in the read and write systemcall * when each file opened by the process is closed. Note that the systemtap * script needs to be running before the open operations occur for * the script to record data. * * This script could be used to to find out which files are slow to load * on a machine. e.g. * * stap iotime.stp -c 'firefox' * * Output format is: * timestamp pid (executabable) info_type path ... * * 200283135 2573 (cupsd) access /etc/printcap read: 0 write: 7063 * 200283143 2573 (cupsd) iotime /etc/printcap time: 69 * */ global start global time_io function timestamp:long() { return gettimeofday_us() - start } function proc:string() { return sprintf("%d (%s)", pid(), execname()) } probe begin { start = gettimeofday_us() } global possible_filename, filehandles, fileread, filewrite probe syscall.open, syscall.openat { possible_filename[tid()] = filename } probe syscall.open.return, syscall.openat.return { // Get filename even if non-dwarf syscall return probe are used. filename = possible_filename[tid()] delete possible_filename[tid()] if (retval != -1) { filehandles[pid(), retval] = filename } else { printf("%d %s access %s fail\n", timestamp(), proc(), filename) } } global read_fds, write_fds probe syscall.read { read_fds[tid()] = fd } probe syscall.read.return { p = pid() // Get fd even if non-dwarf syscall return probe. fd = read_fds[tid()] delete read_fds[tid()] bytes = retval time = gettimeofday_us() - @entry(gettimeofday_us()) if (bytes > 0) fileread[p, fd] <<< bytes time_io[p, fd] <<< time } probe syscall.write { write_fds[tid()] = fd } probe syscall.write.return { p = pid() // Get fd even if non-dwarf syscall return probe. fd = write_fds[tid()] delete write_fds[tid()] bytes = retval time = gettimeofday_us() - @entry(gettimeofday_us()) if (bytes > 0) filewrite[p, fd] <<< bytes time_io[p, fd] <<< time } probe syscall.close { if ([pid(), fd] in filehandles) { printf("%d %s access %s read: %d write: %d\n", timestamp(), proc(), filehandles[pid(), fd], @sum(fileread[pid(), fd]), @sum(filewrite[pid(), fd])) if (@count(time_io[pid(), fd])) printf("%d %s iotime %s time: %d\n", timestamp(), proc(), filehandles[pid(), fd], @sum(time_io[pid(), fd])) } delete fileread[pid(), fd] delete filewrite[pid(), fd] delete filehandles[pid(), fd] delete time_io[pid(),fd] }