opensnoop(8)
๐ฆ opensnoop โ like, the manual page but make it cute ๐ฆ
okay bestie so this is opensnoop from the System Manager's Manual (section 8, we love a section 8 moment ๐
). She traces open() syscalls with all the file details, and she runs on Linux ftrace. Periodt.
โจ NAME โจ
opensnoop โ trace open() syscalls with file details. Uses Linux ftrace. no cap, that's literally her whole job ๐ซถ
โจ SYNOPSIS โจ
opensnoop [-htx] [-d secs] [-p pid] [-L tid] [-n name] [filename]
โจ DESCRIPTION โจ
So what she does is trace open() syscalls, and she shows you the file name (the pathname, bestie) and the returned file descriptor number โ or -1 if it errored out ๐ญ.
This implementation is specifically built to work on older kernel versions, and to work without kernel debuginfo. Iconic of her honestly. The way she does it: dynamic tracing of the return value of getname() as a string, and then associating it with the following open() syscall return. ๐ซ
โ ๏ธ real talk: this approach is kernel version specific, and it may not work on your version. It's a workaround, and a proof of concept for ftrace, until more kernel tracing functionality is available. She's doing her best, okay?
And since this uses ftrace, only the root user can use this tool. root energy only ๐
โจ REQUIREMENTS โจ
FTRACEandKPROBECONFIG- the
syscalls:sys_exit_opentracepoint - the
getname()kernel function - and
awk(yes girl, awk is carrying this whole operation, we stan)
You may already have these enabled and available on recent Linux kernels. ๐
โจ OPTIONS โจ
-dsecs โ set the duration of tracing, in seconds. Trace output will be buffered and printed at the end. This also reduces overheads by buffering in-kernel, instead of printing events as they occur. lowkey efficient of her โจ
The ftrace buffer has a fixed size per-CPU (see /sys/kernel/debug/tracing/buffer_size_kb). If you think events are missing, try increasing that size. ๐
-hโ print usage message. the little "help me help you" moment ๐-nname โ only show processes matching this process name. Partial strings and regular expressions are allowed. This is post-filtered usingawk.-pPID โ only trace this process ID. This is filtered in-kernel. ๐ฅ-LTID โ only trace this thread ID. This is filtered in-kernel. ๐ฅ-tโ include timestamps, in seconds. โฐ-xโ only print failedopen()s. the flop detector ๐- filename โ only show
open()s which match this filename. Partial strings and regular expressions are allowed. This is post-filtered usingawk.
โจ EXAMPLES โจ
Trace all open() syscalls with details:
# opensnoop
Only trace open()s for PID 81:
# opensnoop -p 81
Trace failed open() syscalls:
# opensnoop -x
Trace open() syscalls for filenames containing "conf":
# opensnoop conf
Trace open() syscalls for filenames ending in "log":
# opensnoop 'log$'
โจ FIELDS โจ
TIMEsโ time ofopen()completion, in units of seconds. โฑ๏ธCOMMโ process name (if known).PIDโ process ID.FDโ file descriptor. If this is a successful open, the file descriptor number is shown. If this is unsuccessful,-1is shown. Numbers beginning with0xare hexadecimal. ๐งฎFILEโ filename (pathname) used by theopen()syscall.
โจ OVERHEAD โจ
She reads open() syscalls and getname() kernel functions as they occur. For high rates of opens (> 500/s), the overhead may begin to be measurable. Test yourself, bestie, don't just take my word for it. You can use the -d mode to buffer output, reducing overheads. ๐ซถ
โจ SOURCE โจ
This is from the perf-tools collection.
https://github.com/brendangregg/perf-tools
Also look under the examples directory for a text file containing example usage, output, and commentary for this tool. ๐
โจ OS โจ
Linux ๐ง
โจ STABILITY โจ
Unstable - in development. she's a work in progress and that's her journey ๐ฑ
โจ AUTHOR โจ
Brendan Gregg ๐
โจ SEE ALSO โจ
and that's the whole vibe check, bestie ๐ this page came straight out of the USER COMMANDS section, dated 2014-07-20 โ yes she's vintage, yes she still eats. go trace something, ily ๐ฆ๐
๐ฆ where this page comes from
- debian bookworm: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 ยท GPL-2.0-or-later
- debian trixie: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1 ยท GPL-2.0-or-later
- ubuntu jammy: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 ยท GPL-2.0-or-later
- ubuntu noble: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu1 ยท GPL-2.0-or-later
- ubuntu resolute: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 ยท GPL-2.0-or-later
- ubuntu stonking: perf-tools-unstable 1.0.1~20200130+git49b8cdf-1ubuntu2 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms