statsnoop.bt(8)
β¨ statsnoop.bt β the manual page but make it cute β¨
okay bestie, welcome to statsnoop.bt π this is a page from section 8 of the system manager's manual, and it's literally about tracing stat() syscalls with bpftrace/eBPF. let's get into it π«Ά
πΈ NAME πΈ
statsnoop.bt β trace stat() syscalls. uses bpftrace/eBPF. periodt.
π SYNOPSIS π
statsnoop.bt
that's it. no flags, no arguments, she just goes. main character energy fr π
π¦ DESCRIPTION π¦
so statsnoop traces the stat() syscall, and it shows you which processes are attempting to stat which files. lowkey iconic. why do you care? because it's genuinely useful for figuring out where your config and log files live, and for troubleshooting apps that are failing β especially when they fail on startup π like, that one file it can't find? this tool will tell you.
it traces the tracepoints for statfs(), statx(), newstat(), and newlstat(). ngl, these are not the only stat syscalls β so if you're missing activity, you may need to add more variants yourself. the tool is not gonna gaslight you about it, but she also can't do everything π
and since this uses BPF, only the root user can use this tool. no root, no stats. that's the vibe check and you failed it π
π REQUIREMENTS π
CONFIG_BPFbcc
both. or she's not running. simple as that π
β¨ EXAMPLES β¨
trace all the stat() syscalls:
# statsnoop.bt
ate. no crumbs. π₯
π FIELDS π
here's what every line of output is giving:
- PID β process ID
- TID β thread ID
- COMM β process name
- FD β file descriptor (if it succeeded), or
-1(if it failed) π - ERR β error number (go look at your system's
errno.hbestie) - PATH β the stat path
π₯ OVERHEAD π₯
she traces the stat tracepoints and prints output for each event. and because the rate of this is generally expected to be low β like, < 1000/s low β the overhead is also expected to be negligible. β¨
but if you have an application that's calling a high rate of stat()s? then test and understand the overhead before use. do not just rawdog it. please. π«Ά
π§ SOURCE π§
this is from bpftrace.
https://github.com/iovisor/bpftrace
also, look in the bpftrace distribution for a companion _examples.txt file β it's got example usage, output, and commentary for this tool. so much lore in there π
this is a bpftrace version of the bcc tool of the same name. and heads up: the bcc tool may provide more options and customizations. so if you need more, she's right there.
https://github.com/iovisor/bcc
π OS π
Linux π§ (obviously)
π STABILITY π
Unstable β in development.
so like. she's growing. she's evolving. be nice to her π
π AUTHOR π
Brendan Gregg
the icon, the legend, the moment β
π«Ά SEE ALSO π«Ά
go read those next, bestie, they're the friend group π
and that's the whole page!! from the USER COMMANDS corner of the manual, dated 2018-09-08, this was statsnoop.bt(8) π mwah, go trace something pretty π
β¨
π¦ where this page comes from
- debian bookworm: bpftrace 0.17.0-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms