statsnoop(8)
β¨ NAME β¨
statsnoop π¦ is the manual page for statsnoop(8), and it traces stat() syscalls using Linux eBPF/bcc. Basically it's a spy for file lookups π΅οΈββοΈ
π§ SYNOPSIS π§
statsnoop [-h] [-t] [-x] [-p PID]
π DESCRIPTION π
okay so statsnoop traces the different stat() syscalls and shows you which processes are trying to read info about which files π this is lowkey perfect for finding where config and log files live, or for figuring out why an app is failing, especially on startup π«Ά
It works by tracing various kernel sys_stat() functions with dynamic tracing π bestie, that means it will need updating if those functions ever change π
This makes use of a Linux 4.4 feature (bpf_perf_event_output()). For kernels older than 4.4, check out the version undertools/old, which uses an older mechanism π°οΈ
Since this runs on BPF, only the root user can use this tool π no cap, no exceptions.
π REQUIREMENTS π
You need CONFIG_BPF and bcc β¨
π OPTIONS π
-hβ the usage message, for when you forget what you're doing π-tβ adds a timestamp column, in seconds since the first event, with decimal places β±οΈ-xβ only shows the stats that failed π-p PIDβ traces only this process ID, filtered in-kernel π―
π EXAMPLES π
Trace all stat() syscalls:
# statsnoop
Trace all stat() syscalls, and include timestamps:
# statsnoop -t
Trace only stat() syscalls that failed:
# statsnoop -x
Trace PID 181 only:
# statsnoop -p 181
π FIELDS π
TIME(s)β when the call happened, in seconds β°PIDβ the process ID πͺͺCOMMβ the process name π·οΈFDβ the file descriptor if it worked, or-1if it failed πERRβ the error number (check the system'serrno.hfor the tea β)PATHβ the open path π£οΈ
π₯ OVERHEAD π₯
This traces the kernel stat function and prints output for each event ποΈ the rate is generally expected to be low (< 1000/s), so the overhead should be negligible π«§ but if your app is calling a high rate of stat()s, then test and understand the overhead before you use it, periodt π€
π¦ SOURCE π¦
This is from bcc π
https://github.com/iovisor/bcc
Also look in the bcc distribution for a companion _examples.txt file with example usage, output, and commentary for this tool π
π₯οΈ OS π₯οΈ
Linux π§
π§ͺ STABILITY π§ͺ
Unstable - in development. π§
β AUTHOR β
Brendan Gregg π©βπ»β¨
πΈ SEE ALSO πΈ
opensnoop(1) π«
Anyway, that's the whole tea on statsnoop(8) π«Ά It's from the USER COMMANDS section and dated 2016-02-08 π Stay curious, bestie, and go trace some stats π
β¨
π¦ where this page comes from
- centos-stream 10: bcc-tools 0.36.1-1.el10 Β· Apache-2.0
- centos-stream 9: bcc-tools 0.36.1-1.el9 Β· ASL 2.0
- fedora 43: bcc-tools 0.35.0-2.fc43 Β· Apache-2.0
- fedora 44: bcc-tools 0.35.0-5.fc44 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms