forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statsnoop_example.txt
73 lines (61 loc) · 3.02 KB
/
statsnoop_example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Demonstrations of statsnoop, the Linux eBPF/bcc version.
statsnoop traces the different stat() syscalls system-wide, and prints various
details. Example output:
# ./statsnoop
PID COMM FD ERR PATH
31126 bash 0 0 .
31126 bash -1 2 /usr/local/sbin/iconfig
31126 bash -1 2 /usr/local/bin/iconfig
31126 bash -1 2 /usr/sbin/iconfig
31126 bash -1 2 /usr/bin/iconfig
31126 bash -1 2 /sbin/iconfig
31126 bash -1 2 /bin/iconfig
31126 bash -1 2 /usr/games/iconfig
31126 bash -1 2 /usr/local/games/iconfig
31126 bash -1 2 /apps/python/bin/iconfig
31126 bash -1 2 /mnt/src/llvm/build/bin/iconfig
8902 command-not-fou -1 2 /usr/bin/Modules/Setup
8902 command-not-fou -1 2 /usr/bin/lib/python3.4/os.py
8902 command-not-fou -1 2 /usr/bin/lib/python3.4/os.pyc
8902 command-not-fou 0 0 /usr/lib/python3.4/os.py
8902 command-not-fou -1 2 /usr/bin/pybuilddir.txt
8902 command-not-fou -1 2 /usr/bin/lib/python3.4/lib-dynload
8902 command-not-fou 0 0 /usr/lib/python3.4/lib-dynload
8902 command-not-fou 0 0 /apps/python/lib/python2.7/site-packages
8902 command-not-fou 0 0 /apps/python/lib/python2.7/site-packages
8902 command-not-fou 0 0 /apps/python/lib/python2.7/site-packages
8902 command-not-fou 0 0 /usr/lib/python3.4/
8902 command-not-fou 0 0 /usr/lib/python3.4/
[...]
This output has caught me mistyping a command in another shell, "iconfig"
instead of "ifconfig". The first several lines show the bash shell searching
the $PATH, and failing to find it (ERR == 2 is file not found). Then, a
"command-not-found" program executes (the name is truncated to 16 characters
in the COMM field), which begins the process of searching for and suggesting
a package. ie, this:
# iconfig
No command 'iconfig' found, did you mean:
Command 'vconfig' from package 'vlan' (main)
Command 'fconfig' from package 'redboot-tools' (universe)
Command 'mconfig' from package 'mono-devel' (main)
Command 'iwconfig' from package 'wireless-tools' (main)
Command 'zconfig' from package 'python-zconfig' (universe)
Command 'ifconfig' from package 'net-tools' (main)
iconfig: command not found
statsnoop can be used for general debugging, to see what file information has
been requested, and whether those files exist. It can be used as a companion
to opensnoop, which shows what files were actually opened.
USAGE message:
# ./statsnoop -h
usage: statsnoop [-h] [-t] [-x] [-p PID]
Trace stat() syscalls
optional arguments:
-h, --help show this help message and exit
-t, --timestamp include timestamp on output
-x, --failed only show failed stats
-p PID, --pid PID trace this PID only
examples:
./statsnoop # trace all stat() syscalls
./statsnoop -t # include timestamps
./statsnoop -x # only show failed stats
./statsnoop -p 181 # only trace PID 181