DOKK / manpages / debian 12 / bpfcc-tools / opensnoop-bpfcc.8.en
opensnoop(8) System Manager's Manual opensnoop(8)

opensnoop - Trace open() syscalls. Uses Linux eBPF/bcc.

opensnoop [-h] [-T] [-U] [-x] [-p PID] [-t TID] [-u UID]
[-d DURATION] [-n NAME] [-e] [-f FLAG_FILTER] [-F]
[--cgroupmap MAPPATH] [--mntnsmap MAPPATH]

opensnoop traces the open() syscall, showing which processes are attempting to open which files. This can be useful for determining the location of config and log files, or for troubleshooting applications that are failing, specially on startup.

This works by tracing the kernel sys_open() function using dynamic tracing, and will need updating to match any changes to this function.

This makes use of a Linux 4.4 feature (bpf_perf_event_output()); for kernels older than 4.4, see the version under tools/old, which uses an older mechanism.

Since this uses BPF, only the root user can use this tool.

CONFIG_BPF and bcc.

Print usage message.
Include a timestamp column.
Show UID.
Only print failed opens.
Trace this process ID only (filtered in-kernel).
Trace this thread ID only (filtered in-kernel).
Trace this UID only (filtered in-kernel).
Total duration of trace in seconds.
Only print processes where its name partially matches 'name'
Show extended fields.
Filter on open() flags, e.g., O_WRONLY.
Show full path for an open file with relative path.
Trace cgroups in this BPF map only (filtered in-kernel).
Trace mount namespaces in this BPF map only (filtered in-kernel).

# opensnoop
# opensnoop -d 10
# opensnoop -T
# opensnoop -U
# opensnoop -x
# opensnoop -p 181
# opensnoop -u 1000
# opensnoop -n ed
# opensnoop -e
# opensnoop -f O_WRONLY -f O_RDWR
# opensnoop --cgroupmap /sys/fs/bpf/test01

Time of the call, in seconds.
User ID
Process ID
Thread ID
Process name
File descriptor (if success), or -1 (if failed)
Error number (see the system's errno.h)
Flags passed to open(2), in octal
Open path

This traces the kernel open function and prints output for each event. As the rate of this is generally expected to be low (< 1000/s), the overhead is also expected to be negligible. If you have an application that is calling a high rate of open()s, then test and understand overhead before use.

This is from bcc.

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool.

Linux

Unstable - in development.

Brendan Gregg, Rocky Xing

execsnoop(8), funccount(1)

2020-02-20 USER COMMANDS