Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
b334f110
Commit
b334f110
authored
Feb 04, 2018
by
yonghong-song
Committed by
GitHub
Feb 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1570 from natoscott/master
continue adding --ebpf option to the python tools/ scripts
parents
e6c75684
f13107a3
Changes
47
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
249 additions
and
42 deletions
+249
-42
tools/btrfsdist.py
tools/btrfsdist.py
+5
-1
tools/btrfsslower.py
tools/btrfsslower.py
+5
-1
tools/cpudist.py
tools/cpudist.py
+5
-1
tools/cpuunclaimed.py
tools/cpuunclaimed.py
+5
-1
tools/dbslower.py
tools/dbslower.py
+5
-1
tools/dcsnoop.py
tools/dcsnoop.py
+6
-0
tools/execsnoop.py
tools/execsnoop.py
+8
-1
tools/ext4dist.py
tools/ext4dist.py
+5
-1
tools/ext4slower.py
tools/ext4slower.py
+5
-1
tools/filelife.py
tools/filelife.py
+5
-1
tools/fileslower.py
tools/fileslower.py
+6
-2
tools/filetop.py
tools/filetop.py
+5
-1
tools/funclatency.py
tools/funclatency.py
+5
-1
tools/funcslower.py
tools/funcslower.py
+5
-1
tools/gethostlatency.py
tools/gethostlatency.py
+6
-0
tools/hardirqs.py
tools/hardirqs.py
+5
-1
tools/killsnoop.py
tools/killsnoop.py
+5
-1
tools/llcstat.py
tools/llcstat.py
+9
-2
tools/memleak.py
tools/memleak.py
+6
-0
tools/mountsnoop.py
tools/mountsnoop.py
+5
-0
tools/nfsdist.py
tools/nfsdist.py
+5
-1
tools/nfsslower.py
tools/nfsslower.py
+5
-1
tools/offcputime.py
tools/offcputime.py
+5
-1
tools/offwaketime.py
tools/offwaketime.py
+5
-0
tools/opensnoop.py
tools/opensnoop.py
+5
-1
tools/profile.py
tools/profile.py
+5
-1
tools/runqlat.py
tools/runqlat.py
+5
-1
tools/runqlen.py
tools/runqlen.py
+6
-2
tools/slabratetop.py
tools/slabratetop.py
+5
-1
tools/softirqs.py
tools/softirqs.py
+5
-1
tools/solisten.py
tools/solisten.py
+6
-0
tools/sslsniff.py
tools/sslsniff.py
+5
-1
tools/statsnoop.py
tools/statsnoop.py
+5
-1
tools/syscount.py
tools/syscount.py
+5
-0
tools/tcpaccept.py
tools/tcpaccept.py
+5
-1
tools/tcpconnect.py
tools/tcpconnect.py
+5
-1
tools/tcpconnlat.py
tools/tcpconnlat.py
+5
-1
tools/tcpretrans.py
tools/tcpretrans.py
+5
-1
tools/tcptop.py
tools/tcptop.py
+5
-1
tools/tcptracer.py
tools/tcptracer.py
+6
-0
tools/trace.py
tools/trace.py
+5
-1
tools/ttysnoop.py
tools/ttysnoop.py
+5
-1
tools/wakeuptime.py
tools/wakeuptime.py
+5
-1
tools/xfsdist.py
tools/xfsdist.py
+5
-1
tools/xfsslower.py
tools/xfsslower.py
+5
-1
tools/zfsdist.py
tools/zfsdist.py
+5
-1
tools/zfsslower.py
tools/zfsslower.py
+5
-1
No files found.
tools/btrfsdist.py
View file @
b334f110
...
...
@@ -40,6 +40,8 @@ parser.add_argument("interval", nargs="?",
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
pid
=
args
.
pid
countdown
=
int
(
args
.
count
)
...
...
@@ -183,8 +185,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/btrfsslower.py
View file @
b334f110
...
...
@@ -51,6 +51,8 @@ parser.add_argument("-p", "--pid",
help
=
"trace this PID only"
)
parser
.
add_argument
(
"min_ms"
,
nargs
=
"?"
,
default
=
'10'
,
help
=
"minimum I/O duration to trace, in ms (default 10)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
min_ms
=
int
(
args
.
min_ms
)
pid
=
args
.
pid
...
...
@@ -280,8 +282,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# kernel->user event data: struct data_t
DNAME_INLINE_LEN
=
32
# linux/dcache.h
...
...
tools/cpudist.py
View file @
b334f110
...
...
@@ -44,6 +44,8 @@ parser.add_argument("interval", nargs="?", default=99999999,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
count
)
debug
=
0
...
...
@@ -149,8 +151,10 @@ else:
bpf_text
=
bpf_text
.
replace
(
'STORAGE'
,
'BPF_HISTOGRAM(dist);'
)
bpf_text
=
bpf_text
.
replace
(
'STORE'
,
'dist.increment(bpf_log2l(delta));'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event
=
"finish_task_switch"
,
fn_name
=
"sched_switch"
)
...
...
tools/cpuunclaimed.py
View file @
b334f110
...
...
@@ -87,6 +87,8 @@ parser.add_argument("interval", nargs="?", default=-1,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
count
)
frequency
=
99
...
...
@@ -155,8 +157,10 @@ int do_perf_event(struct bpf_perf_event_data *ctx)
"""
# code substitutions
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF & perf_events
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/dbslower.py
View file @
b334f110
...
...
@@ -51,6 +51,8 @@ parser.add_argument("-x", "--exe", type=str,
dest
=
"path"
,
metavar
=
"PATH"
,
help
=
"path to binary"
)
parser
.
add_argument
(
"-m"
,
"--threshold"
,
type
=
int
,
default
=
1
,
help
=
"trace queries slower than this threshold (ms)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
threshold_ns
=
args
.
threshold
*
1000000
...
...
@@ -196,8 +198,10 @@ else:
bpf
=
BPF
(
text
=
program
,
usdt_contexts
=
usdts
)
if
args
.
verbose
:
if
args
.
verbose
or
args
.
ebpf
:
print
(
program
)
if
args
.
ebpf
:
exit
()
class
Data
(
ct
.
Structure
):
_fields_
=
[
...
...
tools/dcsnoop.py
View file @
b334f110
...
...
@@ -38,6 +38,8 @@ parser = argparse.ArgumentParser(
epilog
=
examples
)
parser
.
add_argument
(
"-a"
,
"--all"
,
action
=
"store_true"
,
help
=
"trace all lookups (default is fails only)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
# define BPF program
...
...
@@ -132,6 +134,10 @@ class Data(ct.Structure):
(
"filename"
,
ct
.
c_char
*
MAX_FILE_LEN
),
]
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
if
args
.
all
:
...
...
tools/execsnoop.py
View file @
b334f110
...
...
@@ -46,6 +46,8 @@ parser.add_argument("-l", "--line",
help
=
"only print commands where arg contains this line (regex)"
)
parser
.
add_argument
(
"--max-args"
,
default
=
"20"
,
help
=
"maximum number of arguments parsed and displayed, defaults to 20"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
# define BPF program
...
...
@@ -128,8 +130,13 @@ int kretprobe__sys_execve(struct pt_regs *ctx)
}
"""
bpf_text
=
bpf_text
.
replace
(
"MAXARG"
,
args
.
max_args
)
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
.
replace
(
"MAXARG"
,
args
.
max_args
)
)
b
=
BPF
(
text
=
bpf_text
)
# header
if
args
.
timestamp
:
...
...
tools/ext4dist.py
View file @
b334f110
...
...
@@ -40,6 +40,8 @@ parser.add_argument("interval", nargs="?",
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
pid
=
args
.
pid
countdown
=
int
(
args
.
count
)
...
...
@@ -163,8 +165,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/ext4slower.py
View file @
b334f110
...
...
@@ -51,6 +51,8 @@ parser.add_argument("-p", "--pid",
help
=
"trace this PID only"
)
parser
.
add_argument
(
"min_ms"
,
nargs
=
"?"
,
default
=
'10'
,
help
=
"minimum I/O duration to trace, in ms (default 10)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
min_ms
=
int
(
args
.
min_ms
)
pid
=
args
.
pid
...
...
@@ -274,8 +276,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# kernel->user event data: struct data_t
DNAME_INLINE_LEN
=
32
# linux/dcache.h
...
...
tools/filelife.py
View file @
b334f110
...
...
@@ -34,6 +34,8 @@ parser = argparse.ArgumentParser(
epilog
=
examples
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -114,8 +116,10 @@ if args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/fileslower.py
View file @
b334f110
...
...
@@ -50,6 +50,8 @@ parser.add_argument("-a", "--all-files", action="store_true",
help
=
"include non-regular file types (sockets, FIFOs, etc)"
)
parser
.
add_argument
(
"min_ms"
,
nargs
=
"?"
,
default
=
'10'
,
help
=
"minimum I/O duration to trace, in ms (default 10)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
min_ms
=
int
(
args
.
min_ms
)
tgid
=
args
.
tgid
...
...
@@ -185,11 +187,13 @@ if args.all_files:
else
:
bpf_text
=
bpf_text
.
replace
(
'TYPE_FILTER'
,
'!S_ISREG(mode)'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
,
)
b
=
BPF
(
text
=
bpf_text
)
# I'd rather trace these via new_sync_read/new_sync_write (which used to be
# do_sync_read/do_sync_write), but those became static. So trace these from
...
...
tools/filetop.py
View file @
b334f110
...
...
@@ -47,6 +47,8 @@ parser.add_argument("interval", nargs="?", default=1,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
interval
=
int
(
args
.
interval
)
countdown
=
int
(
args
.
count
)
...
...
@@ -149,8 +151,10 @@ if args.all_files:
else
:
bpf_text
=
bpf_text
.
replace
(
'TYPE_FILTER'
,
'!S_ISREG(mode)'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/funclatency.py
View file @
b334f110
...
...
@@ -63,6 +63,8 @@ parser.add_argument("-v", "--verbose", action="store_true",
help
=
"print the BPF program (for debugging purposes)"
)
parser
.
add_argument
(
"pattern"
,
help
=
"search expression for functions"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
def
bail
(
error
):
...
...
@@ -184,8 +186,10 @@ else:
bpf_text
=
bpf_text
.
replace
(
'ENTRYSTORE'
,
''
)
bpf_text
=
bpf_text
.
replace
(
'STORE'
,
'dist.increment(bpf_log2l(delta));'
)
if
args
.
verbose
:
if
args
.
verbose
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# signal handler
def
signal_ignore
(
signal
,
frame
):
...
...
tools/funcslower.py
View file @
b334f110
...
...
@@ -55,6 +55,8 @@ parser.add_argument("-v", "--verbose", action="store_true",
help
=
"print the BPF program for debugging purposes"
)
parser
.
add_argument
(
metavar
=
"function"
,
nargs
=
"+"
,
dest
=
"functions"
,
help
=
"function(s) to trace"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
# fractions are allowed, but rounded to an integer nanosecond
...
...
@@ -165,8 +167,10 @@ int trace_%d(struct pt_regs *ctx) {
}
"""
%
(
i
,
i
)
if
args
.
verbose
:
if
args
.
verbose
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/gethostlatency.py
View file @
b334f110
...
...
@@ -31,6 +31,8 @@ parser = argparse.ArgumentParser(
epilog
=
examples
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
,
type
=
int
,
default
=-
1
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
# load BPF program
...
...
@@ -94,6 +96,10 @@ int do_return(struct pt_regs *ctx) {
return 0;
}
"""
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_uprobe
(
name
=
"c"
,
sym
=
"getaddrinfo"
,
fn_name
=
"do_entry"
,
pid
=
args
.
pid
)
b
.
attach_uprobe
(
name
=
"c"
,
sym
=
"gethostbyname"
,
fn_name
=
"do_entry"
,
...
...
tools/hardirqs.py
View file @
b334f110
...
...
@@ -41,6 +41,8 @@ parser.add_argument("interval", nargs="?", default=99999999,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"outputs"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
outputs
)
if
args
.
count
and
(
args
.
dist
or
args
.
nanoseconds
):
...
...
@@ -136,8 +138,10 @@ else:
'bpf_probe_read(&key.name, sizeof(key.name), name);'
+
'u64 zero = 0, *vp = dist.lookup_or_init(&key, &zero);'
+
'(*vp) += delta;'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/killsnoop.py
View file @
b334f110
...
...
@@ -32,6 +32,8 @@ parser.add_argument("-x", "--failed", action="store_true",
help
=
"only show failed kill syscalls"
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -102,8 +104,10 @@ if args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/llcstat.py
View file @
b334f110
...
...
@@ -28,10 +28,12 @@ parser.add_argument(
help
=
"Sample one in this many number of cache reference / miss events"
)
parser
.
add_argument
(
"duration"
,
nargs
=
"?"
,
default
=
10
,
help
=
"Duration, in seconds, to run"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
# load BPF program
b
=
BPF
(
text
=
"""
b
pf_
text
=
"""
#include <linux/ptrace.h>
#include <uapi/linux/bpf_perf_event.h>
...
...
@@ -71,8 +73,13 @@ int on_cache_ref(struct bpf_perf_event_data *ctx) {
return 0;
}
"""
)
"""
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_perf_event
(
ev_type
=
PerfType
.
HARDWARE
,
ev_config
=
PerfHWConfig
.
CACHE_MISSES
,
fn_name
=
"on_cache_miss"
,
sample_period
=
args
.
sample_period
)
...
...
tools/memleak.py
View file @
b334f110
...
...
@@ -97,6 +97,8 @@ parser.add_argument("-Z", "--max-size", type=int,
help
=
"capture only allocations smaller than this size"
)
parser
.
add_argument
(
"-O"
,
"--obj"
,
type
=
str
,
default
=
"c"
,
help
=
"attach to allocator functions in the specified object"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
...
...
@@ -384,6 +386,10 @@ if not kernel_trace:
stack_flags
+=
"|BPF_F_USER_STACK"
bpf_source
=
bpf_source
.
replace
(
"STACK_FLAGS"
,
stack_flags
)
if
args
.
ebpf
:
print
(
bpf_source
)
exit
()
bpf
=
BPF
(
text
=
bpf_source
)
if
not
kernel_trace
:
...
...
tools/mountsnoop.py
View file @
b334f110
...
...
@@ -393,10 +393,15 @@ def main():
parser
=
argparse
.
ArgumentParser
(
description
=
'trace mount() and umount() syscalls'
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
mounts
=
{}
umounts
=
{}
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
b
=
bcc
.
BPF
(
text
=
bpf_text
)
b
[
'events'
].
open_perf_buffer
(
functools
.
partial
(
print_event
,
mounts
,
umounts
))
...
...
tools/nfsdist.py
View file @
b334f110
...
...
@@ -34,6 +34,8 @@ parser.add_argument("interval", nargs="?",
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
pid
=
args
.
pid
countdown
=
int
(
args
.
count
)
...
...
@@ -124,8 +126,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/nfsslower.py
View file @
b334f110
...
...
@@ -53,6 +53,8 @@ parser.add_argument("-j", "--csv", action="store_true",
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"Trace this pid only"
)
parser
.
add_argument
(
"min_ms"
,
nargs
=
"?"
,
default
=
'10'
,
help
=
"Minimum IO duration to trace in ms (default=10ms)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
min_ms
=
int
(
args
.
min_ms
)
pid
=
args
.
pid
...
...
@@ -236,8 +238,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# kernel->user event data: struct data_t
DNAME_INLINE_LEN
=
32
# linux/dcache.h
...
...
tools/offcputime.py
View file @
b334f110
...
...
@@ -91,6 +91,8 @@ parser.add_argument("-M", "--max-block-time", default=(1 << 64) - 1,
parser
.
add_argument
(
"--state"
,
type
=
positive_int
,
help
=
"filter on this thread state bitmask (eg, 2 == TASK_UNINTERRUPTIBLE"
+
") see include/linux/sched.h"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
if
args
.
pid
and
args
.
tgid
:
parser
.
error
(
"specify only one of -p and -t"
)
...
...
@@ -222,8 +224,10 @@ if args.kernel_threads_only and args.user_stacks_only:
"doesn't make sense."
,
file
=
stderr
)
exit
(
1
)
if
(
debug
)
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/offwaketime.py
View file @
b334f110
...
...
@@ -88,6 +88,8 @@ parser.add_argument("-M", "--max-block-time", default=(1 << 64) - 1,
type
=
positive_nonzero_int
,
help
=
"the amount of time in microseconds under which we "
+
"store traces (default U64_MAX)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
folded
=
args
.
folded
duration
=
int
(
args
.
duration
)
...
...
@@ -235,6 +237,9 @@ else:
stack_context
=
"user + kernel"
bpf_text
=
bpf_text
.
replace
(
'USER_STACK_GET'
,
user_stack_get
)
bpf_text
=
bpf_text
.
replace
(
'KERNEL_STACK_GET'
,
kernel_stack_get
)
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/opensnoop.py
View file @
b334f110
...
...
@@ -45,6 +45,8 @@ parser.add_argument("-d", "--duration",
help
=
"total duration of trace in seconds"
)
parser
.
add_argument
(
"-n"
,
"--name"
,
help
=
"only print process names containing this name"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
if
args
.
duration
:
...
...
@@ -125,8 +127,10 @@ elif args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/profile.py
View file @
b334f110
...
...
@@ -97,6 +97,8 @@ parser.add_argument("--stack-storage-size", default=10240,
parser
.
add_argument
(
"duration"
,
nargs
=
"?"
,
default
=
99999999
,
type
=
positive_nonzero_int
,
help
=
"duration of trace, in seconds"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
# option logic
args
=
parser
.
parse_args
()
...
...
@@ -208,8 +210,10 @@ if not args.folded:
else
:
print
(
"... Hit Ctrl-C to end."
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF & perf_events
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/runqlat.py
View file @
b334f110
...
...
@@ -58,6 +58,8 @@ parser.add_argument("interval", nargs="?", default=99999999,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
count
)
debug
=
0
...
...
@@ -169,8 +171,10 @@ else:
bpf_text
=
bpf_text
.
replace
(
'STORAGE'
,
'BPF_HISTOGRAM(dist);'
)
bpf_text
=
bpf_text
.
replace
(
'STORE'
,
'dist.increment(bpf_log2l(delta));'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/runqlen.py
View file @
b334f110
...
...
@@ -48,6 +48,8 @@ parser.add_argument("interval", nargs="?", default=99999999,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
count
)
debug
=
0
...
...
@@ -158,6 +160,7 @@ int do_perf_event()
}
"""
# code substitutions
if
args
.
cpus
:
bpf_text
=
bpf_text
.
replace
(
'STORAGE'
,
'BPF_HISTOGRAM(dist, cpu_key_t);'
)
...
...
@@ -174,9 +177,10 @@ if check_runnable_weight_field():
else
:
bpf_text
=
bpf_text
.
replace
(
'RUNNABLE_WEIGHT_FIELD'
,
''
)
# code substitutions
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/slabratetop.py
View file @
b334f110
...
...
@@ -41,6 +41,8 @@ parser.add_argument("interval", nargs="?", default=1,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
interval
=
int
(
args
.
interval
)
countdown
=
int
(
args
.
count
)
...
...
@@ -90,8 +92,10 @@ int kprobe__kmem_cache_alloc(struct pt_regs *ctx, struct kmem_cache *cachep)
return 0;
}
"""
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/softirqs.py
View file @
b334f110
...
...
@@ -38,6 +38,8 @@ parser.add_argument("interval", nargs="?", default=99999999,
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
countdown
=
int
(
args
.
count
)
if
args
.
nanoseconds
:
...
...
@@ -110,8 +112,10 @@ else:
'key.vec = valp->vec; '
+
'u64 zero = 0, *vp = dist.lookup_or_init(&key, &zero); '
+
'(*vp) += delta;'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/solisten.py
View file @
b334f110
...
...
@@ -42,6 +42,8 @@ parser.add_argument("-p", "--pid", default=0, type=int,
help
=
"trace this PID only"
)
parser
.
add_argument
(
"-n"
,
"--netns"
,
default
=
0
,
type
=
int
,
help
=
"trace this Network Namespace only"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
# BPF Program
...
...
@@ -190,6 +192,10 @@ if __name__ == "__main__":
bpf_text
=
bpf_text
.
replace
(
"##FILTER_PID##"
,
pid_filter
)
bpf_text
=
bpf_text
.
replace
(
"##FILTER_NETNS##"
,
netns_filter
)
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
# Initialize BPF
b
=
BPF
(
text
=
bpf_text
)
b
[
"listen_evt"
].
open_perf_buffer
(
event_printer
(
args
.
show_netns
))
...
...
tools/sslsniff.py
View file @
b334f110
...
...
@@ -39,6 +39,8 @@ parser.add_argument("-g", "--no-gnutls", action="store_false", dest="gnutls",
help
=
"do not show GnuTLS calls."
)
parser
.
add_argument
(
'-d'
,
'--debug'
,
dest
=
'debug'
,
action
=
'count'
,
default
=
0
,
help
=
'debug mode.'
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
...
...
@@ -119,8 +121,10 @@ if args.pid:
else
:
prog
=
prog
.
replace
(
'FILTER'
,
''
)
if
args
.
debug
:
if
args
.
debug
or
args
.
ebpf
:
print
(
prog
)
if
args
.
ebpf
:
exit
()
b
=
BPF
(
text
=
prog
)
...
...
tools/statsnoop.py
View file @
b334f110
...
...
@@ -34,6 +34,8 @@ parser.add_argument("-x", "--failed", action="store_true",
help
=
"only show failed stats"
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -100,8 +102,10 @@ if args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/syscount.py
View file @
b334f110
...
...
@@ -401,6 +401,8 @@ parser.add_argument("-P", "--process", action="store_true",
help
=
"count by process and not by syscall"
)
parser
.
add_argument
(
"-l"
,
"--list"
,
action
=
"store_true"
,
help
=
"print list of recognized syscalls and exit"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
if
args
.
list
:
...
...
@@ -488,6 +490,9 @@ if args.latency:
text
=
"#define LATENCY
\
n
"
+
text
if
args
.
process
:
text
=
"#define BY_PROCESS
\
n
"
+
text
if
args
.
ebpf
:
print
(
text
)
exit
()
bpf
=
BPF
(
text
=
text
)
...
...
tools/tcpaccept.py
View file @
b334f110
...
...
@@ -36,6 +36,8 @@ parser.add_argument("-t", "--timestamp", action="store_true",
help
=
"include timestamp on output"
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -123,8 +125,10 @@ if args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# event data
TASK_COMM_LEN
=
16
# linux/sched.h
...
...
tools/tcpconnect.py
View file @
b334f110
...
...
@@ -42,6 +42,8 @@ parser.add_argument("-p", "--pid",
help
=
"trace this PID only"
)
parser
.
add_argument
(
"-P"
,
"--port"
,
help
=
"comma-separated list of destination ports to trace."
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -162,8 +164,10 @@ if args.port:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
''
)
bpf_text
=
bpf_text
.
replace
(
'FILTER_PORT'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# event data
TASK_COMM_LEN
=
16
# linux/sched.h
...
...
tools/tcpconnlat.py
View file @
b334f110
...
...
@@ -53,6 +53,8 @@ parser.add_argument("duration_ms", nargs="?", default=0,
help
=
"minimum duration to trace (ms)"
)
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
help
=
"print the BPF program for debugging purposes"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
if
args
.
duration_ms
:
...
...
@@ -186,8 +188,10 @@ if args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
or
args
.
verbose
:
if
debug
or
args
.
verbose
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/tcpretrans.py
View file @
b334f110
...
...
@@ -37,6 +37,8 @@ parser.add_argument("-l", "--lossprobe", action="store_true",
help
=
"include tail loss probe attempts"
)
parser
.
add_argument
(
"-c"
,
"--count"
,
action
=
"store_true"
,
help
=
"count occurred retransmits per flow"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -189,8 +191,10 @@ else:
bpf_text
=
bpf_text
.
replace
(
"IPV4_CORE"
,
"ipv4_events.perf_submit(ctx, &data4, sizeof(data4));"
)
bpf_text
=
bpf_text
.
replace
(
"IPV6_CORE"
,
"ipv6_events.perf_submit(ctx, &data6, sizeof(data6));"
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# event data
class
Data_ipv4
(
ct
.
Structure
):
...
...
tools/tcptop.py
View file @
b334f110
...
...
@@ -60,6 +60,8 @@ parser.add_argument("interval", nargs="?", default=1, type=range_check,
help
=
"output interval, in seconds (default 1)"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=-
1
,
type
=
range_check
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -189,8 +191,10 @@ if args.pid:
'if (pid != %s) { return 0; }'
%
args
.
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
def
pid_to_comm
(
pid
):
try
:
...
...
tools/tcptracer.py
View file @
b334f110
...
...
@@ -32,6 +32,8 @@ parser.add_argument("-N", "--netns", default=0, type=int,
help
=
"trace this Network Namespace only"
)
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
help
=
"include Network Namespace in the output"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
bpf_text
=
"""
...
...
@@ -622,6 +624,10 @@ if args.netns:
bpf_text
=
bpf_text
.
replace
(
'##FILTER_PID##'
,
pid_filter
)
bpf_text
=
bpf_text
.
replace
(
'##FILTER_NETNS##'
,
netns_filter
)
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event
=
"tcp_v4_connect"
,
fn_name
=
"trace_connect_v4_entry"
)
...
...
tools/trace.py
View file @
b334f110
...
...
@@ -660,6 +660,8 @@ trace -I 'linux/fs_struct.h' 'mntns_install "users = %d", $task->fs->users'
"as either full path, "
"or relative to current working directory, "
"or relative to default kernel header search path"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
self
.
args
=
parser
.
parse_args
()
if
self
.
args
.
tgid
and
self
.
args
.
pid
:
parser
.
error
(
"only one of -p and -L may be specified"
)
...
...
@@ -690,8 +692,10 @@ trace -I 'linux/fs_struct.h' 'mntns_install "users = %d", $task->fs->users'
self
.
program
+=
probe
.
generate_program
(
self
.
args
.
include_self
)
if
self
.
args
.
verbose
:
if
self
.
args
.
verbose
or
self
.
args
.
ebpf
:
print
(
self
.
program
)
if
self
.
args
.
ebpf
:
exit
()
def
_attach_probes
(
self
):
usdt_contexts
=
[]
...
...
tools/ttysnoop.py
View file @
b334f110
...
...
@@ -42,6 +42,8 @@ parser.add_argument("-C", "--noclear", action="store_true",
help
=
"don't clear the screen"
)
parser
.
add_argument
(
"device"
,
default
=
"-1"
,
help
=
"path to a tty device (eg, /dev/tty0) or pts number"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -91,8 +93,10 @@ int kprobe__tty_write(struct pt_regs *ctx, struct file *file,
"""
bpf_text
=
bpf_text
.
replace
(
'PTS'
,
str
(
pi
.
st_ino
))
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/wakeuptime.py
View file @
b334f110
...
...
@@ -71,6 +71,8 @@ parser.add_argument("-M", "--max-block-time", default=(1 << 64) - 1,
type
=
positive_nonzero_int
,
help
=
"the amount of time in microseconds under which we "
+
"store traces (default U64_MAX)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
folded
=
args
.
folded
duration
=
int
(
args
.
duration
)
...
...
@@ -155,8 +157,10 @@ bpf_text = bpf_text.replace('STACK_STORAGE_SIZE', str(args.stack_storage_size))
bpf_text
=
bpf_text
.
replace
(
'MINBLOCK_US_VALUE'
,
str
(
args
.
min_block_time
))
bpf_text
=
bpf_text
.
replace
(
'MAXBLOCK_US_VALUE'
,
str
(
args
.
max_block_time
))
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# initialize BPF
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/xfsdist.py
View file @
b334f110
...
...
@@ -37,6 +37,8 @@ parser.add_argument("interval", nargs="?",
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
pid
=
args
.
pid
countdown
=
int
(
args
.
count
)
...
...
@@ -126,8 +128,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/xfsslower.py
View file @
b334f110
...
...
@@ -48,6 +48,8 @@ parser.add_argument("-p", "--pid",
help
=
"trace this PID only"
)
parser
.
add_argument
(
"min_ms"
,
nargs
=
"?"
,
default
=
'10'
,
help
=
"minimum I/O duration to trace, in ms (default 10)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
min_ms
=
int
(
args
.
min_ms
)
pid
=
args
.
pid
...
...
@@ -229,8 +231,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# kernel->user event data: struct data_t
DNAME_INLINE_LEN
=
32
# linux/dcache.h
...
...
tools/zfsdist.py
View file @
b334f110
...
...
@@ -37,6 +37,8 @@ parser.add_argument("interval", nargs="?",
help
=
"output interval, in seconds"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
default
=
99999999
,
help
=
"number of outputs"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
pid
=
args
.
pid
countdown
=
int
(
args
.
count
)
...
...
@@ -126,8 +128,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# load BPF program
b
=
BPF
(
text
=
bpf_text
)
...
...
tools/zfsslower.py
View file @
b334f110
...
...
@@ -51,6 +51,8 @@ parser.add_argument("-p", "--pid",
help
=
"trace this PID only"
)
parser
.
add_argument
(
"min_ms"
,
nargs
=
"?"
,
default
=
'10'
,
help
=
"minimum I/O duration to trace, in ms (default 10)"
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
min_ms
=
int
(
args
.
min_ms
)
pid
=
args
.
pid
...
...
@@ -233,8 +235,10 @@ if args.pid:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'pid != %s'
%
pid
)
else
:
bpf_text
=
bpf_text
.
replace
(
'FILTER_PID'
,
'0'
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# kernel->user event data: struct data_t
DNAME_INLINE_LEN
=
32
# linux/dcache.h
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment