statsnoop.bt(8)
π statsnoop.bt β bestie's guide to stalking your stat() syscalls
okay so. this is a page from the System Manager's Manual, section 8, and the tool is called statsnoop.bt. it's giving detective energy, but for syscalls. let's get into it π
β¨ NAME β¨
statsnoop.bt β trace stat() syscalls. no cap, that's the whole vibe. it runs on bpftrace/eBPF.
πΈ SYNOPSIS πΈ
statsnoop.bt
that's it. that's the whole command. no flags, no arguments, just pure main character energy π«Ά
π¦ DESCRIPTION π¦
okay so statsnoop traces the stat() syscall, and it shows you which processes are trying to stat which files. literally a receipts printer for file-lookups π
why do you care? because this is lowkey the cheat code for:
- figuring out where your config and log files actually live
- troubleshooting apps that are failing, especially on startup (ngl startup failures are the WORST, they just β¨vanishβ¨)
so here's the tea: this tool traces the tracepoints for statfs(), statx(), newstat(), and newlstat(). but bestie, listen β those are not the only stat syscalls out there. so if you're missing activity, you might need to add more variants yourself. iykyk π
and the biggest caveat of all: since this uses BPF, only the root user can use this tool. root only. periodt. π
π REQUIREMENTS π
CONFIG_BPFbcc
that's the whole list. if you have those, you're slaying β¨
π₯ EXAMPLES π₯
trace all the stat() syscalls, every single one:
# statsnoop.bt
ate. no notes. π
π FIELDS π
here's what each column is serving:
- PID β Process ID. who's doing it.
- COMM β Process name. the name of who's doing it.
- ERR β Error number (go check the system's
errno.hfor what each one means) - PATH β Stat path. the file they were trying to peek at π
β OVERHEAD β
okay so this traces the stat tracepoints and prints output for each event. and the way that this is generally expected to be low-rate (< 1000/s), the overhead is also expected to be negligible. so you're fine, probably π«Ά
BUT β if you have an application that's calling a high rate of stat()s, then please, for the love of everything, test and understand overhead before use. do not just yolo it. π
π SOURCE π
this is from bpftrace.
https://github.com/bpftrace/bpftrace
also! look in the bpftrace distribution for a companion _examples.txt file β it's got example usage, output, and commentary for this tool. it's the director's commentary track, basically π¬
and for the lore: this is a bpftrace version of the bcc tool of the same name. the bcc tool may provide more options and customizations, so if you want extra toppings, go look there:
https://github.com/iovisor/bcc
π§ OS π§
Linux π§ (obviously bestie)
π STABILITY π
Unstable β in development.
translation: it works, but it's still growing. be gentle. it's in its development arc π±
π AUTHOR π
Brendan Gregg
(the icon. the legend. we stan.) π
πΈ SEE ALSO πΈ
and that's the whole page, bestie!! this one came out of the USER COMMANDS section, dated 2018-09-08, and it's filed under statsnoop.bt(8). go trace some syscalls and slay π
β¨π¦
π¦ where this page comes from
- alpine 3.24: bpftrace-tools-doc 0.26.1-r0 Β· Apache-2.0
- arch rolling: bpftrace 0.27.0-2 Β· Apache-2.0
- centos-stream 10: bpftrace 0.26.1-1.el10 Β· Apache-2.0
- centos-stream 9: bpftrace 0.26.1-1.el9 Β· ASL 2.0
- nixos 26.05: bpftrace 0.25.1
- nixpkgs unstable: bpftrace 0.27.1
- ubuntu resolute: bpftrace 0.25.0-1ubuntu1 Β· Apache-2.0
- ubuntu stonking: bpftrace 0.25.0-1ubuntu2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms