fluent-plugin-perf-tools 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rubocop.yml +26 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +5 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +5 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +43 -0
  10. data/Rakefile +17 -0
  11. data/bin/console +15 -0
  12. data/bin/setup +8 -0
  13. data/fluent-plugin-perf-tools.gemspec +48 -0
  14. data/lib/fluent/plugin/in_perf_tools.rb +42 -0
  15. data/lib/fluent/plugin/perf_tools/cachestat.rb +65 -0
  16. data/lib/fluent/plugin/perf_tools/command.rb +30 -0
  17. data/lib/fluent/plugin/perf_tools/version.rb +9 -0
  18. data/lib/fluent/plugin/perf_tools.rb +11 -0
  19. data/perf-tools/LICENSE +339 -0
  20. data/perf-tools/README.md +205 -0
  21. data/perf-tools/bin/bitesize +1 -0
  22. data/perf-tools/bin/cachestat +1 -0
  23. data/perf-tools/bin/execsnoop +1 -0
  24. data/perf-tools/bin/funccount +1 -0
  25. data/perf-tools/bin/funcgraph +1 -0
  26. data/perf-tools/bin/funcslower +1 -0
  27. data/perf-tools/bin/functrace +1 -0
  28. data/perf-tools/bin/iolatency +1 -0
  29. data/perf-tools/bin/iosnoop +1 -0
  30. data/perf-tools/bin/killsnoop +1 -0
  31. data/perf-tools/bin/kprobe +1 -0
  32. data/perf-tools/bin/opensnoop +1 -0
  33. data/perf-tools/bin/perf-stat-hist +1 -0
  34. data/perf-tools/bin/reset-ftrace +1 -0
  35. data/perf-tools/bin/syscount +1 -0
  36. data/perf-tools/bin/tcpretrans +1 -0
  37. data/perf-tools/bin/tpoint +1 -0
  38. data/perf-tools/bin/uprobe +1 -0
  39. data/perf-tools/deprecated/README.md +1 -0
  40. data/perf-tools/deprecated/execsnoop-proc +150 -0
  41. data/perf-tools/deprecated/execsnoop-proc.8 +80 -0
  42. data/perf-tools/deprecated/execsnoop-proc_example.txt +46 -0
  43. data/perf-tools/disk/bitesize +175 -0
  44. data/perf-tools/examples/bitesize_example.txt +63 -0
  45. data/perf-tools/examples/cachestat_example.txt +58 -0
  46. data/perf-tools/examples/execsnoop_example.txt +153 -0
  47. data/perf-tools/examples/funccount_example.txt +126 -0
  48. data/perf-tools/examples/funcgraph_example.txt +2178 -0
  49. data/perf-tools/examples/funcslower_example.txt +110 -0
  50. data/perf-tools/examples/functrace_example.txt +341 -0
  51. data/perf-tools/examples/iolatency_example.txt +350 -0
  52. data/perf-tools/examples/iosnoop_example.txt +302 -0
  53. data/perf-tools/examples/killsnoop_example.txt +62 -0
  54. data/perf-tools/examples/kprobe_example.txt +379 -0
  55. data/perf-tools/examples/opensnoop_example.txt +47 -0
  56. data/perf-tools/examples/perf-stat-hist_example.txt +149 -0
  57. data/perf-tools/examples/reset-ftrace_example.txt +88 -0
  58. data/perf-tools/examples/syscount_example.txt +297 -0
  59. data/perf-tools/examples/tcpretrans_example.txt +93 -0
  60. data/perf-tools/examples/tpoint_example.txt +210 -0
  61. data/perf-tools/examples/uprobe_example.txt +321 -0
  62. data/perf-tools/execsnoop +292 -0
  63. data/perf-tools/fs/cachestat +167 -0
  64. data/perf-tools/images/perf-tools_2016.png +0 -0
  65. data/perf-tools/iolatency +296 -0
  66. data/perf-tools/iosnoop +296 -0
  67. data/perf-tools/kernel/funccount +146 -0
  68. data/perf-tools/kernel/funcgraph +259 -0
  69. data/perf-tools/kernel/funcslower +248 -0
  70. data/perf-tools/kernel/functrace +192 -0
  71. data/perf-tools/kernel/kprobe +270 -0
  72. data/perf-tools/killsnoop +263 -0
  73. data/perf-tools/man/man8/bitesize.8 +70 -0
  74. data/perf-tools/man/man8/cachestat.8 +111 -0
  75. data/perf-tools/man/man8/execsnoop.8 +104 -0
  76. data/perf-tools/man/man8/funccount.8 +76 -0
  77. data/perf-tools/man/man8/funcgraph.8 +166 -0
  78. data/perf-tools/man/man8/funcslower.8 +129 -0
  79. data/perf-tools/man/man8/functrace.8 +123 -0
  80. data/perf-tools/man/man8/iolatency.8 +116 -0
  81. data/perf-tools/man/man8/iosnoop.8 +169 -0
  82. data/perf-tools/man/man8/killsnoop.8 +100 -0
  83. data/perf-tools/man/man8/kprobe.8 +162 -0
  84. data/perf-tools/man/man8/opensnoop.8 +113 -0
  85. data/perf-tools/man/man8/perf-stat-hist.8 +111 -0
  86. data/perf-tools/man/man8/reset-ftrace.8 +49 -0
  87. data/perf-tools/man/man8/syscount.8 +96 -0
  88. data/perf-tools/man/man8/tcpretrans.8 +93 -0
  89. data/perf-tools/man/man8/tpoint.8 +140 -0
  90. data/perf-tools/man/man8/uprobe.8 +168 -0
  91. data/perf-tools/misc/perf-stat-hist +223 -0
  92. data/perf-tools/net/tcpretrans +311 -0
  93. data/perf-tools/opensnoop +280 -0
  94. data/perf-tools/syscount +192 -0
  95. data/perf-tools/system/tpoint +232 -0
  96. data/perf-tools/tools/reset-ftrace +123 -0
  97. data/perf-tools/user/uprobe +390 -0
  98. metadata +349 -0
@@ -0,0 +1,263 @@
1
+ #!/bin/bash
2
+ #
3
+ # killsnoop - trace kill() syscalls with signal/process details.
4
+ # Written using Linux ftrace.
5
+ #
6
+ # This traces kill() syscalls, showing which process killed which pid and
7
+ # returns the returncode (0 for success, -1 for error).
8
+ #
9
+ # This implementation is designed to work on older kernel versions, and without
10
+ # kernel debuginfo. It works by dynamic tracing of the return value of kill()
11
+ # and associating it with the previous kill() syscall return.
12
+ # This approach is kernel version specific, and may not work on your version.
13
+ # It is a workaround, and proof of concept for ftrace, until more kernel tracing
14
+ # functionality is available.
15
+ #
16
+ # USAGE: ./killsnoop [-hst] [-d secs] [-p pid] [-n name]
17
+ #
18
+ # Run "killsnoop -h" for full usage.
19
+ #
20
+ # REQUIREMENTS: FTRACE and KPROBE CONFIG, syscalls:sys_enter_kill and
21
+ # syscalls:sys_exit_kill kernel tracepoints (you may already have these
22
+ # on recent kernels) and awk.
23
+ #
24
+ # From perf-tools: https://github.com/brendangregg/perf-tools
25
+ #
26
+ # See the killsnoop(8) man page (in perf-tools) for more info.
27
+ #
28
+ # COPYRIGHT: Copyright (c) 2014 Brendan Gregg.
29
+ # COPYRIGHT: Copyright (c) 2014 Martin Probst.
30
+ #
31
+ # This program is free software; you can redistribute it and/or
32
+ # modify it under the terms of the GNU General Public License
33
+ # as published by the Free Software Foundation; either version 2
34
+ # of the License, or (at your option) any later version.
35
+ #
36
+ # This program is distributed in the hope that it will be useful,
37
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
38
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
+ # GNU General Public License for more details.
40
+ #
41
+ # You should have received a copy of the GNU General Public License
42
+ # along with this program; if not, write to the Free Software Foundation,
43
+ # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
44
+ #
45
+ # (http://www.gnu.org/copyleft/gpl.html)
46
+ #
47
+ # 20-Jul-2014 Brendan Gregg Templated this.
48
+ # 13-Sep-2014 Martin Probst Created this.
49
+
50
+ ### default variables
51
+ tracing=/sys/kernel/debug/tracing
52
+ flock=/var/tmp/.ftrace-lock; wroteflock=0
53
+ opt_duration=0; duration=; opt_name=0; name=; opt_pid=0; pid=; ftext=
54
+ opt_time=0; opt_fail=0; opt_file=0; file=
55
+ kevent_entry=events/syscalls/sys_enter_kill
56
+ kevent_return=events/syscalls/sys_exit_kill
57
+ trap ':' INT QUIT TERM PIPE HUP # sends execution to end tracing section
58
+
59
+ function usage {
60
+ cat <<-END >&2
61
+ USAGE: killsnoop [-hst] [-d secs] [-p PID] [-n name] [filename]
62
+ -d seconds # trace duration, and use buffers
63
+ -n name # process name to match
64
+ -p PID # PID to match on kill issue
65
+ -t # include time (seconds)
66
+ -s # human readable signal names
67
+ -h # this usage message
68
+ eg,
69
+ killsnoop # watch kill()s live (unbuffered)
70
+ killsnoop -d 1 # trace 1 sec (buffered)
71
+ killsnoop -p 181 # trace kill()s issued to PID 181 only
72
+
73
+ See the man page and example file for more info.
74
+ END
75
+ exit
76
+ }
77
+
78
+ function warn {
79
+ if ! eval "$@"; then
80
+ echo >&2 "WARNING: command failed \"$@\""
81
+ fi
82
+ }
83
+
84
+ function end {
85
+ # disable tracing
86
+ echo 2>/dev/null
87
+ echo "Ending tracing..." 2>/dev/null
88
+ cd $tracing
89
+ warn "echo 0 > $kevent_entry/enable"
90
+ warn "echo 0 > $kevent_return/enable"
91
+ warn "echo > trace"
92
+ (( wroteflock )) && warn "rm $flock"
93
+ }
94
+
95
+ function die {
96
+ echo >&2 "$@"
97
+ exit 1
98
+ }
99
+
100
+ function edie {
101
+ # die with a quiet end()
102
+ echo >&2 "$@"
103
+ exec >/dev/null 2>&1
104
+ end
105
+ exit 1
106
+ }
107
+
108
+ ### process options
109
+ while getopts d:hn:p:st opt
110
+ do
111
+ case $opt in
112
+ d) opt_duration=1; duration=$OPTARG ;;
113
+ n) opt_name=1; name=$OPTARG ;;
114
+ p) opt_pid=1; pid=$OPTARG ;;
115
+ t) opt_time=1 ;;
116
+ s) opt_fancy=1 ;;
117
+ h|?) usage ;;
118
+ esac
119
+ done
120
+ shift $(( $OPTIND - 1 ))
121
+ (( $# )) && usage
122
+
123
+ ### option logic
124
+ (( opt_pid && opt_name )) && die "ERROR: use either -p or -n."
125
+ (( opt_pid )) && ftext=" issued to PID $pid"
126
+ (( opt_name )) && ftext=" issued by process name \"$name\""
127
+ if (( opt_duration )); then
128
+ echo "Tracing kill()s$ftext for $duration seconds (buffered)..."
129
+ else
130
+ echo "Tracing kill()s$ftext. Ctrl-C to end."
131
+ fi
132
+
133
+ ### select awk
134
+ # workaround for mawk fflush()
135
+ [[ -x /usr/bin/mawk ]] && awk="mawk" && mawk -W interactive && \
136
+ [ $? -eq 0 ] && awk="mawk -W interactive"
137
+ # workaround for gawk strtonum()
138
+ [[ -x /usr/bin/gawk ]] && awk="gawk --non-decimal-data"
139
+
140
+ ### check permissions
141
+ cd $tracing || die "ERROR: accessing tracing. Root user? Kernel has FTRACE?
142
+ debugfs mounted? (mount -t debugfs debugfs /sys/kernel/debug)"
143
+
144
+ ### ftrace lock
145
+ [[ -e $flock ]] && die "ERROR: ftrace may be in use by PID $(cat $flock) $flock"
146
+ echo $$ > $flock || die "ERROR: unable to write $flock."
147
+ wroteflock=1
148
+
149
+ ### setup and begin tracing
150
+ echo nop > current_tracer
151
+ if ! echo 1 > $kevent_entry/enable; then
152
+ edie "ERROR: enabling kill() entry tracepoint Exiting."
153
+ fi
154
+ if ! echo 1 > $kevent_return/enable; then
155
+ edie "ERROR: enabling kill() return tracepoint. Exiting."
156
+ fi
157
+ (( opt_time )) && printf "%-16s " "TIMEs"
158
+ printf "%-16.16s %-6s %-8s %-10s %4s\n" "COMM" "PID" "TPID" "SIGNAL" "RETURN"
159
+
160
+ #
161
+ # Determine output format. It may be one of the following (newest first):
162
+ # TASK-PID CPU# |||| TIMESTAMP FUNCTION
163
+ # TASK-PID CPU# TIMESTAMP FUNCTION
164
+ # To differentiate between them, the number of header fields is counted,
165
+ # and an offset set, to skip the extra column when needed.
166
+ #
167
+ offset=$($awk 'BEGIN { o = 0; }
168
+ $1 == "#" && $2 ~ /TASK/ && NF == 6 { o = 1; }
169
+ $2 ~ /TASK/ { print o; exit }' trace)
170
+
171
+ ### print trace buffer
172
+ warn "echo > trace"
173
+ ( if (( opt_duration )); then
174
+ # wait then dump buffer
175
+ sleep $duration
176
+ cat trace
177
+ else
178
+ # print buffer live
179
+ cat trace_pipe
180
+ fi ) | $awk -v o=$offset -v opt_name=$opt_name -v name=$name \
181
+ -v opt_duration=$opt_duration -v opt_time=$opt_time \
182
+ -v opt_pid=$pid -v opt_fancy=$opt_fancy '
183
+ # fancy signal names
184
+ BEGIN {
185
+ signals[1] = "SIGHUP"
186
+ signals[2] = "SIGINT"
187
+ signals[3] = "SIGQUIT"
188
+ signals[4] = "SIGILL"
189
+ signals[6] = "SIGABRT"
190
+ signals[8] = "SIGFPE"
191
+ signals[9] = "SIGKILL"
192
+ signals[11] = "SIGSEGV"
193
+ signals[13] = "SIGPIPE"
194
+ signals[14] = "SIGALRM"
195
+ signals[15] = "SIGTERM"
196
+ signals[10] = "SIGUSR1"
197
+ signals[12] = "SIGUSR2"
198
+ signals[17] = "SIGCHLD"
199
+ signals[18] = "SIGCONT"
200
+ signals[19] = "SIGSTOP"
201
+ signals[20] = "SIGTSTP"
202
+ signals[21] = "SIGTTIN"
203
+ signals[22] = "SIGTTOU"
204
+ }
205
+
206
+ # common fields
207
+ $1 != "#" {
208
+ # task name can contain dashes
209
+ comm = pid = $1
210
+ sub(/-[0-9][0-9]*/, "", comm)
211
+ if (opt_name && match(comm, name) == 0)
212
+ next
213
+ sub(/.*-/, "", pid)
214
+ }
215
+
216
+ # sys_kill() entry
217
+ $1 != "#" && $(4+o) ~ /sys_kill/ && $(5+o) !~ /->/ {
218
+ #
219
+ # eg: ... sys_kill(pid:...
220
+ #
221
+ kpid = $(5+o)
222
+ signal = $(7+o)
223
+ sub(/,$/, "", kpid)
224
+ sub(/\)$/, "", signal)
225
+ kpid = int("0x"kpid)
226
+ signal = int("0x"signal)
227
+ current[pid,"kpid"] = kpid
228
+ current[pid,"signal"] = signal
229
+ }
230
+
231
+ # sys_kill exit
232
+ $1 != "#" && $(5+o) ~ /->/ {
233
+ rv = int($NF)
234
+ killed_pid = current[pid,"kpid"]
235
+ signal = current[pid,"signal"]
236
+
237
+ delete current[pid,"kpid"]
238
+ delete current[pid,"signal"]
239
+
240
+ if(opt_pid && killed_pid != opt_pid) {
241
+ next
242
+ }
243
+
244
+ if (opt_time) {
245
+ time = $(3+o); sub(":", "", time)
246
+ printf "%-16s ", time
247
+ }
248
+
249
+ if (opt_fancy) {
250
+ if (signals[signal] != "") {
251
+ signal = signals[signal]
252
+ }
253
+ }
254
+
255
+ printf "%-16.16s %-6s %-8s %-10s %-4s\n", comm, pid, killed_pid, signal,
256
+ rv
257
+ }
258
+
259
+ $0 ~ /LOST.*EVENTS/ { print "WARNING: " $0 > "/dev/stderr" }
260
+ '
261
+
262
+ ### end tracing
263
+ end
@@ -0,0 +1,70 @@
1
+ .TH bitesize 8 "2014-07-07" "USER COMMANDS"
2
+ .SH NAME
3
+ bitesize \- show disk I/O size as a histogram. Uses Linux perf_events.
4
+ .SH SYNOPSIS
5
+ .B bitesize
6
+ [-h] [-b buckets] [seconds]
7
+ .SH DESCRIPTION
8
+ This can be used to characterize the distribution of block device (disk) I/O
9
+ sizes. To study block device I/O in more detail, see iosnoop(8).
10
+
11
+ This uses multiple counting tracepoints with different filters, one for each
12
+ histogram bucket. While this is summarized in-kernel, the use of multiple
13
+ tracepoints does add addiitonal overhead, which is more evident if you add
14
+ more buckets. In the future this functionality will be available in an
15
+ efficient way in the kernel, and this tool can be rewritten.
16
+ .SH REQUIREMENTS
17
+ Linux perf_events: add linux-tools-common, run "perf", then add any additional
18
+ packages it requests. This also requires the block:block_rq_issue tracepoint,
19
+ which should already be available in recent kernels.
20
+ .SH OPTIONS
21
+ .TP
22
+ \-h
23
+ Usage message.
24
+ .TP
25
+ \-b buckets
26
+ Specify a list of bucket points for the histogram as a string (eg, "10 500
27
+ 1000"). The histogram will include buckets for less-than the minimum, and
28
+ greater-than-or-equal-to the maximum. If a single value is specified, two
29
+ statistics only are gathered: for less-than and for greater-than-or-equal-to.
30
+ The overhead is relative to the number of buckets, so only specifying a
31
+ single value costs the lowest overhead.
32
+ .TP
33
+ seconds
34
+ Number of seconds to trace. If not specified, this runs until Ctrl-C.
35
+ .SH EXAMPLES
36
+ .TP
37
+ Trace read() syscalls until Ctrl-C, and show histogram of requested size:
38
+ #
39
+ .B bitesize syscalls:sys_enter_read count
40
+ .SH FIELDS
41
+ .TP
42
+ Kbytes
43
+ Kbyte range of the histogram bucket.
44
+ .TP
45
+ I/O
46
+ Number of I/O that occurred in this range while tracing.
47
+ .TP
48
+ Distribution
49
+ ASCII histogram representation of the I/O column.
50
+ .SH OVERHEAD
51
+ While the counts are performed in-kernel, there is one tracepoint used per
52
+ histogram bucket, so the overheads are higher than usual (relative to the
53
+ number of buckets) than function counting using perf stat. The lowest
54
+ overhead is when \-b is used to specify one bucket only, bifurcating
55
+ statistics.
56
+ .SH SOURCE
57
+ This is from the perf-tools collection.
58
+ .IP
59
+ https://github.com/brendangregg/perf-tools
60
+ .PP
61
+ Also look under the examples directory for a text file containing example
62
+ usage, output, and commentary for this tool.
63
+ .SH OS
64
+ Linux
65
+ .SH STABILITY
66
+ Unstable - in development.
67
+ .SH AUTHOR
68
+ Brendan Gregg
69
+ .SH SEE ALSO
70
+ iosnoop(8), iolatency(8), iostat(1)
@@ -0,0 +1,111 @@
1
+ .TH cachestat 8 "2014-12-28" "USER COMMANDS"
2
+ .SH NAME
3
+ cachestat \- Measure page cache hits/misses. Uses Linux ftrace.
4
+ .SH SYNOPSIS
5
+ .B cachestat
6
+ [\-Dht] [interval]
7
+ .SH DESCRIPTION
8
+ This tool provides basic cache hit/miss statistics for the Linux page cache.
9
+
10
+ Its current implementation uses Linux ftrace dynamic function profiling to
11
+ create custom in-kernel counters, which is a workaround until such counters
12
+ can be built-in to the kernel. Specifically, four kernel functions are counted:
13
+ .IP
14
+ mark_page_accessed() for measuring cache accesses
15
+ .IP
16
+ mark_buffer_dirty() for measuring cache writes
17
+ .IP
18
+ add_to_page_cache_lru() for measuring page additions
19
+ .IP
20
+ account_page_dirtied() for measuring page dirties
21
+ .PP
22
+ It is possible that these functions have been renamed (or are different
23
+ logically) for your kernel version, and this script will not work as-is.
24
+ This was written for a Linux 3.13 kernel, and tested on a few others versions.
25
+ This script is a sandcastle: the kernel may wash some away, and you'll
26
+ need to rebuild.
27
+
28
+ This program's implementation can be improved in the future when other
29
+ kernel capabilities are made available. If you need a more reliable tool now,
30
+ then consider other tracing alternatives (eg, SystemTap). This tool is really
31
+ a proof of concept to see what ftrace can currently do.
32
+
33
+ WARNING: This uses dynamic tracing of kernel functions, and could cause
34
+ kernel panics or freezes. Test, and know what you are doing, before use.
35
+ It also traces cache activity, which can be frequent, and cost some overhead.
36
+ The statistics should be treated as best-effort: there may be some error
37
+ margin depending on unusual workload types.
38
+
39
+ Since this uses ftrace, only the root user can use this tool.
40
+ .SH REQUIREMENTS
41
+ CONFIG_FUNCTION_PROFILER, which you may already have enabled and available on
42
+ recent kernels, and awk.
43
+ .SH OPTIONS
44
+ .TP
45
+ \-D
46
+ Include extra fields for debug purposes (see script).
47
+ .TP
48
+ \-h
49
+ Print usage message.
50
+ .TP
51
+ \-t
52
+ Include timestamps in units of seconds.
53
+ .TP
54
+ interval
55
+ Output interval in seconds. Default is 1.
56
+ .SH EXAMPLES
57
+ .TP
58
+ Show per-second page cache statistics:
59
+ #
60
+ .B cachestat
61
+ .SH FIELDS
62
+ .TP
63
+ TIME
64
+ Time, in HH:MM:SS.
65
+ .TP
66
+ HITS
67
+ Number of page cache hits (reads). Each hit is for one memory page (the size
68
+ depends on your processor architecture; commonly 4 Kbytes). Since this tool
69
+ outputs at a timed interval, this field indicates the cache hit rate.
70
+ .TP
71
+ MISSES
72
+ Number of page cache misses (reads from storage I/O). Each miss is for one
73
+ memory page. Cache misses should be causing disk I/O. Run iostat(1) for
74
+ correlation (although the miss count and size by the time disk I/O is issued
75
+ can differ due to I/O subsystem merging).
76
+ .TP
77
+ DIRTIES
78
+ Number of times a page in the page cache was written to and thus "dirtied".
79
+ The same page may be counted multiple times per interval, if it is written
80
+ to multiple times. This field gives an indication of how much cache churn there
81
+ is, caused by applications writing data.
82
+ .TP
83
+ RATIO
84
+ The ratio of cache hits to total cache accesses (hits + misses), as a
85
+ percentage.
86
+ .TP
87
+ BUFFERS_MB
88
+ Size of the buffer cache, for disk I/O. From /proc/meminfo.
89
+ .TP
90
+ CACHED_MB
91
+ Size of the page cache, for file system I/O. From /proc/meminfo.
92
+ .SH OVERHEAD
93
+ This tool currently uses ftrace function profiling, which provides efficient
94
+ in-kernel counters. However, the functions profiled are executed frequently,
95
+ so the overheads can add up. Test and measure before use. My own testing
96
+ showed around a 2% loss in application performance while this tool was running.
97
+ .SH SOURCE
98
+ This is from the perf-tools collection.
99
+ .IP
100
+ https://github.com/brendangregg/perf-tools
101
+ .PP
102
+ Also look under the examples directory for a text file containing example
103
+ usage, output, and commentary for this tool.
104
+ .SH OS
105
+ Linux
106
+ .SH STABILITY
107
+ Unstable - in development.
108
+ .SH AUTHOR
109
+ Brendan Gregg
110
+ .SH SEE ALSO
111
+ iostat(1), iosnoop(8)
@@ -0,0 +1,104 @@
1
+ .TH execsnoop 8 "2014-07-07" "USER COMMANDS"
2
+ .SH NAME
3
+ execsnoop \- trace process exec() with arguments. Uses Linux ftrace.
4
+ .SH SYNOPSIS
5
+ .B execsnoop
6
+ [\-hrt] [\-a argc] [\-d secs] [name]
7
+ .SH DESCRIPTION
8
+ execsnoop traces process execution, showing PID, PPID, and argument details
9
+ if possible.
10
+
11
+ This traces exec() from the fork()->exec() sequence, which means it won't
12
+ catch new processes that only fork(). With the -r option, it will also catch
13
+ processes that re-exec. It makes a best-effort attempt to retrieve the program
14
+ arguments and PPID; if these are unavailable, 0 and "[?]" are printed
15
+ respectively. There is also a limit to the number of arguments printed (by
16
+ default, 8), which can be increased using -a.
17
+
18
+ This implementation is designed to work on older kernel versions, and without
19
+ kernel debuginfo. It works by dynamic tracing an execve kernel function to
20
+ read the arguments from the %si register. The stub_execve() function is tried
21
+ first, and then the do_execve() function. The sched:sched_process_fork
22
+ tracepoint, is used for the PPID. Tracing registers and kernel functions is
23
+ an unstable technique, and this tool may not work for some kernels or platforms.
24
+
25
+ This program is a workaround that should be
26
+ improved in the future when other kernel capabilities are made available. If
27
+ you need a more reliable tool now, then consider other tracing alternatives
28
+ (eg, SystemTap). This tool is really a proof of concept to see what ftrace can
29
+ currently do.
30
+
31
+ Since this uses ftrace, only the root user can use this tool.
32
+ .SH REQUIREMENTS
33
+ FTRACE and KPROBE CONFIG, sched:sched_process_fork tracepoint,
34
+ and either the stub_execve() or do_execve() kernel function. You may already
35
+ have these on recent kernels. And awk.
36
+ .SH OPTIONS
37
+ .TP
38
+ \-a argc
39
+ Maximum number of arguments to show. The default is 8, and the maximum allowed
40
+ is 16. If execsnoop thinks it has truncated the argument list, an ellipsis
41
+ "[...]" will be shown.
42
+ .TP
43
+ \-d seconds
44
+ Duration to trace, in seconds. This also uses in-kernel buffering.
45
+ .TP
46
+ \-h
47
+ Print usage message.
48
+ .TP
49
+ \-r
50
+ Include re-exec()s.
51
+ .TP
52
+ \-t
53
+ Include timestamps in units of seconds.
54
+ .TP
55
+ name
56
+ Only show processes that match this name.
57
+ Partials and regular expressions are allowed, as this is filtered in
58
+ user space by awk.
59
+ .SH EXAMPLES
60
+ .TP
61
+ Trace all new processes and arguments (if possible):
62
+ #
63
+ .B execsnoop
64
+ .TP
65
+ Trace all new process names containing the text "http":
66
+ #
67
+ .B execsnoop http
68
+ .SH FIELDS
69
+ .TP
70
+ TIMEs
71
+ Time of the exec(), in seconds.
72
+ .TP
73
+ PID
74
+ Process ID.
75
+ .TP
76
+ PPID
77
+ Parent process ID, if this was able to be read. If it wasn't, 0 is printed.
78
+ .TP
79
+ ARGS
80
+ Command line arguments, if these were able to be read. If they aren't able to be
81
+ read, "[?]" is printed (which would be due to a limitation in this tools
82
+ implementation, since this is workaround for older kernels; if you need
83
+ reliable argument tracing, use a different tracer). They will be truncated
84
+ to the argc limit, and an ellipsis "[...]" may be printed if execsnoop is
85
+ aware of the truncation.
86
+ .SH OVERHEAD
87
+ This reads and processes exec() events in user space as they occur. Since the
88
+ rate of exec() is expected to be low (< 500/s), the overhead is expected to
89
+ be small or negligible.
90
+ .SH SOURCE
91
+ This is from the perf-tools collection.
92
+ .IP
93
+ https://github.com/brendangregg/perf-tools
94
+ .PP
95
+ Also look under the examples directory for a text file containing example
96
+ usage, output, and commentary for this tool.
97
+ .SH OS
98
+ Linux
99
+ .SH STABILITY
100
+ Unstable - in development.
101
+ .SH AUTHOR
102
+ Brendan Gregg
103
+ .SH SEE ALSO
104
+ top(1)
@@ -0,0 +1,76 @@
1
+ .TH funccount 8 "2014-07-19" "USER COMMANDS"
2
+ .SH NAME
3
+ funccount \- count kernel function calls matching specified wildcards. Uses Linux ftrace.
4
+ .SH SYNOPSIS
5
+ .B funccount
6
+ [\-hT] [\-i secs] [\-d secs] [\-t top] funcstring
7
+ .SH DESCRIPTION
8
+ This tool is a quick way to determine which kernel functions are being called,
9
+ and at what rate. It uses ftrace function profiling capabilities.
10
+
11
+ WARNING: This uses dynamic tracing of (what can be many) kernel functions,
12
+ and could cause kernel panics or freezes. Test, and know what you are doing,
13
+ before use.
14
+
15
+ Since this uses ftrace, only the root user can use this tool.
16
+ .SH REQUIREMENTS
17
+ CONFIG_FUNCTION_PROFILER, which you may already have enabled and available on
18
+ recent kernels, and awk.
19
+ .SH OPTIONS
20
+ \-d seconds
21
+ Total duration of the trace.
22
+ .TP
23
+ \-h
24
+ Print usage message.
25
+ .TP
26
+ \-i seconds
27
+ Print an interval summary every so many seconds.
28
+ .TP
29
+ \-t top
30
+ Print top number of entries only.
31
+ .TP
32
+ \-T
33
+ Include timestamp on each summary.
34
+ .TP
35
+ funcstring
36
+ A function name to trace, which may include file glob style wildcards ("*") at
37
+ the beginning or ending of a string only. Eg, "vfs*" means match "vfs" followed
38
+ by anything.
39
+ .SH EXAMPLES
40
+ .TP
41
+ Count every kernel function beginning with "bio_", until Ctrl-C is hit:
42
+ #
43
+ .B funccount 'bio_*'
44
+ .TP
45
+ Count every "tcp_*" kernel function, and print a summary every one second, five in total:
46
+ #
47
+ .B funccount \-i 1 \-d 5 'tcp_*'
48
+ .TP
49
+ Count every "ext4*" kernel function, and print the top 20 when Ctrl-C is hit:
50
+ #
51
+ .B funccount \-t 20 'ext4*'
52
+ .SH FIELDS
53
+ .TP
54
+ FUNC
55
+ Kernel function name.
56
+ .TP
57
+ COUNT
58
+ Number of times this function was called during the tracing interval.
59
+ .SH OVERHEAD
60
+ This uses the ftrace profiling framework, which does in-kernel counts,
61
+ lowering the overhead (compared to tracing each event).
62
+ .SH SOURCE
63
+ This is from the perf-tools collection:
64
+ .IP
65
+ https://github.com/brendangregg/perf-tools
66
+ .PP
67
+ Also look under the examples directory for a text file containing example
68
+ usage, output, and commentary for this tool.
69
+ .SH OS
70
+ Linux
71
+ .SH STABILITY
72
+ Unstable - in development.
73
+ .SH AUTHOR
74
+ Brendan Gregg
75
+ .SH SEE ALSO
76
+ functrace(8)