/
usr
/
share
/
systemtap
/
examples
/
io
/
/usr/share/systemtap/examples/io
mkdir
upload
Name
Size
Mode
Actions
capture_ssl_master_secrets.meta
664
0644
edit
dl
rm
capture_ssl_master_secrets.stp
1090
0755
edit
dl
rm
capture_ssl_master_secrets.txt
1907
0644
edit
dl
rm
deviceseeks.meta
490
0644
edit
dl
rm
deviceseeks.stp
1292
0755
edit
dl
rm
deviceseeks.txt
5395
0644
edit
dl
rm
disktop.meta
381
0644
edit
dl
rm
disktop.stp
1794
0755
edit
dl
rm
eatmydata.meta
337
0644
edit
dl
rm
eatmydata.stp
1188
0755
edit
dl
rm
eatmydata.txt
304
0644
edit
dl
rm
enospc.meta
332
0644
edit
dl
rm
enospc.stp
2318
0755
edit
dl
rm
inodewatch.meta
475
0644
edit
dl
rm
inodewatch.stp
245
0755
edit
dl
rm
inodewatch2.meta
504
0644
edit
dl
rm
inodewatch2.stp
390
0755
edit
dl
rm
ioblktime.meta
769
0644
edit
dl
rm
ioblktime.stp
788
0755
edit
dl
rm
iodevstats.meta
738
0644
edit
dl
rm
iodevstats.stp
1152
0755
edit
dl
rm
iodevstats.txt
528
0644
edit
dl
rm
iostat-scsi.meta
608
0644
edit
dl
rm
iostat-scsi.stp
4366
0755
edit
dl
rm
iostat-scsi.txt
481
0644
edit
dl
rm
iostats.meta
671
0644
edit
dl
rm
iostats.stp
1154
0755
edit
dl
rm
iostats.txt
361
0644
edit
dl
rm
iotime.meta
1024
0644
edit
dl
rm
iotime.stp
2893
0755
edit
dl
rm
iotop.meta
410
0644
edit
dl
rm
iotop.stp
624
0755
edit
dl
rm
io_submit.meta
508
0644
edit
dl
rm
io_submit.stp
1906
0755
edit
dl
rm
io_submit.tcl
140
0644
edit
dl
rm
mbrwatch.meta
559
0644
edit
dl
rm
mbrwatch.stp
234
0755
edit
dl
rm
mbrwatch.tcl
140
0644
edit
dl
rm
mbrwatch.txt
788
0644
edit
dl
rm
nfs_func_users.meta
665
0644
edit
dl
rm
nfs_func_users.stp
341
0755
edit
dl
rm
slowvfs.meta
426
0644
edit
dl
rm
slowvfs.stp
281
0755
edit
dl
rm
switchfile.meta
330
0644
edit
dl
rm
switchfile.stp
231
0644
edit
dl
rm
traceaio.c
2624
0644
edit
dl
rm
traceaio.meta
331
0644
edit
dl
rm
traceaio.stp
1825
0755
edit
dl
rm
traceaio.txt
2761
0644
edit
dl
rm
traceio.meta
403
0644
edit
dl
rm
traceio.stp
1384
0755
edit
dl
rm
traceio2.meta
400
0644
edit
dl
rm
traceio2.stp
494
0755
edit
dl
rm
ttyspy.meta
521
0644
edit
dl
rm
ttyspy.stp
1750
0755
edit
dl
rm
ttyspy.txt
455
0644
edit
dl
rm
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 <http://www.gnu.org/licenses/>. * * 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] }
Save
cmd:
run