opensnoop1m
Snoop file opens as they occur. uses dtrace.
Usage
opensnoop [{-a | -A | -ceFghstvxZ}]
[-f
pathname]
[-n
name]
[-p
PID]
Overview
opensnoop tracks file opens. As a process issues a file open, details such as UID, PID and pathname are printed out.
The returned file descriptor is printed, a value of -1 indicates an error. This can be useful for troubleshooting to determine if applications are attempting to open files that do not exist.
Since this uses DTrace, only users with root privileges can run this command.
Options
-
-a -
print all data
-
-A -
dump all data, space delimited
-
-c -
print current working directory of process
-
-e -
print errno value
-
-F -
print the flags passed to open
-
-g -
print full command arguments
-
-s -
print start time, us
-
-t -
print user stack trace
-
-v -
print start time, string
-
-x -
only print failed opens
-
-Z -
print zonename
-
-f pathname -
file pathname to snoop
-
-n name -
process name to snoop
-
-p PID -
process ID to snoop
Examples
Default output, print file opens by process as they occur,
|
# |
|---|---|
Print human readable timestamps,
|
# |
See error codes,
|
# |
Snoop this file only,
|
# |
Fields
ZONE
|
Zone name |
|---|---|
UID
|
User ID |
PID
|
Process ID |
PPID
|
Parent Process ID |
FD
|
File Descriptor (-1 is error) |
FLAGS
|
Flags passed to open |
ERR
|
errno value (see /usr/include/sys/errno.h) |
CWD
|
current working directory of process |
PATH
|
pathname for file open |
COMM
|
command name for the process |
ARGS
|
argument listing for the process |
TIME
|
timestamp for the open event, us |
STRTIME
|
timestamp for the open event, string |
Documentation
See the DTraceToolkit for further documentation under the Docs directory. The DTraceToolkit docs may include full worked examples with verbose descriptions explaining the output.
Exit
opensnoop will run forever until Ctrl-C is hit.
Releases
115 releases since Mac OS X 10.5; the text changed 3 times.
-F since OS X 10.10;
-t since OS X 10.10.