Created
July 6, 2016 06:06
-
-
Save syshack/73c0dd3e5fe3b65d3672d2f2eb2d68ee to your computer and use it in GitHub Desktop.
进程IO监控
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global file_rw_top | |
global exe | |
probe begin { | |
printf("Ctrl-C break\n") | |
} | |
function rwtrace(pid, fd, size, type) { | |
if ( size > 0 ) { | |
if ( pid() == $1 ) { | |
file = @cast(task_current(), "task_struct")->files->fdt->fd[fd] | |
filename = fullpath_struct_file(task_current(), file) | |
exe = execname() | |
} | |
if ( filename != "" ) { | |
if ( (file->f_inode->i_mode & 0170000) == 0100000 ) { | |
file_rw_top[type, filename] += size | |
} | |
} | |
} | |
} | |
probe syscall.read.return { | |
rwtrace($1, $fd, $return, "read") | |
} | |
probe syscall.write.return { | |
rwtrace($1, $fd, $return, "write") | |
} | |
probe end { | |
printf("\nexecname(pid) op filenames size(n)\n") | |
foreach ( [type, filename] in file_rw_top- ) { | |
size = file_rw_top[type, filename] | |
printf("%s(%u) %s %s size(%ld)\n", exe, $1, type, filename, size); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment