-
Notifications
You must be signed in to change notification settings - Fork 4k
tools/filetop: Add directory filter #5300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add support to filtop to filter by directory. Signed-off-by: Srivathsa Dara <[email protected]>
6c8f442
to
ac91de6
Compare
@@ -163,6 +173,16 @@ | |||
bpf_text = bpf_text.replace('TYPE_FILTER', '0') | |||
else: | |||
bpf_text = bpf_text.replace('TYPE_FILTER', '!S_ISREG(mode)') | |||
if args.directory: | |||
try: | |||
directory_inode = os.lstat(args.directory)[stat.ST_INO] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the target directory is a symbolic link, the directory_inode might differ from the target's inode. Does this behave as intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I used os.lstat, which doesn't follow symlinks, so currently if a symlink is provided as an argument, it doesn't report any activity. Switching to os.stat should fix this by properly following the symlink to its target. I'll update the PR accordingly.
from subprocess import call | ||
|
||
# arguments | ||
examples = """examples: | ||
./filetop # file I/O top, 1 second refresh | ||
./filetop -C # don't clear the screen | ||
./filetop -p 181 # PID 181 only | ||
./filetop -d /home/user # trace files in /home/user directory only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current functionality is good, but adding support for including subdirectories would make it even more powerful.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that makes sense. I'll work on adding support for subdirectories.
Thanks for the input.
Add support to filetop to filter by directory.
Signed-off-by: Srivathsa Dara [email protected]