Skip to content

Instantly share code, notes, and snippets.

@syshack
Created July 6, 2016 06:16
Show Gist options
  • Save syshack/e06cdd8d43acb9af41646d6398c73e6f to your computer and use it in GitHub Desktop.
Save syshack/e06cdd8d43acb9af41646d6398c73e6f to your computer and use it in GitHub Desktop.
全系统IO监控
global file_read_top
global file_write_top
probe begin {
printf("Ctrl-C break\n")
}
probe syscall.read.return {
if ( $return > 0 ) {
file = @cast(task_current(), "task_struct")->files->fdt->fd[$fd]
filename = fullpath_struct_file(task_current(), file)
if ( filename != "" ) {
if ( (file->f_inode->i_mode & 0170000) == 0100000 ) {
file_read_top[pid(), execname(), filename] += $return
}
}
}
}
probe syscall.write.return {
if ( $return > 0 ) {
file = @cast(task_current(), "task_struct")->files->fdt->fd[$fd]
filename = fullpath_struct_file(task_current(), file)
if ( filename != "" ) {
if ( (file->f_inode->i_mode & 0170000) == 0100000 ) {
file_write_top[pid(), execname(), filename] += $return
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment