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
bb95ef2f
Commit
bb95ef2f
authored
Jan 21, 2018
by
yonghong-song
Committed by
GitHub
Jan 21, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1531 from natoscott/master
Allow for sharing of python tools/ scripts
parents
fb8bbfe1
1a197dbf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
7 deletions
+24
-7
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+4
-3
tools/biolatency.py
tools/biolatency.py
+5
-1
tools/biotop.py
tools/biotop.py
+10
-2
tools/tcplife.py
tools/tcplife.py
+5
-1
No files found.
src/python/bcc/__init__.py
View file @
bb95ef2f
...
...
@@ -287,6 +287,8 @@ class BPF(object):
if
text
:
self
.
module
=
lib
.
bpf_module_create_c_from_string
(
text
.
encode
(
"ascii"
),
self
.
debug
,
cflags_array
,
len
(
cflags_array
))
if
not
self
.
module
:
raise
Exception
(
"Failed to compile BPF text:
\
n
%s"
%
text
)
else
:
src_file
=
BPF
.
_find_file
(
src_file
)
hdr_file
=
BPF
.
_find_file
(
hdr_file
)
...
...
@@ -296,7 +298,6 @@ class BPF(object):
else
:
self
.
module
=
lib
.
bpf_module_create_c
(
src_file
.
encode
(
"ascii"
),
self
.
debug
,
cflags_array
,
len
(
cflags_array
))
if
not
self
.
module
:
raise
Exception
(
"Failed to compile BPF module %s"
%
src_file
)
...
...
tools/biolatency.py
View file @
bb95ef2f
...
...
@@ -40,6 +40,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
...
...
@@ -103,8 +105,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/biotop.py
View file @
bb95ef2f
...
...
@@ -40,6 +40,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
)
...
...
@@ -55,7 +57,7 @@ def signal_ignore(signal, frame):
print
()
# load BPF program
b
=
BPF
(
text
=
"""
b
pf_text
=
"""
#include <uapi/linux/ptrace.h>
#include <linux/blkdev.h>
...
...
@@ -163,7 +165,13 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
return 0;
}
"""
,
debug
=
0
)
"""
if
args
.
ebpf
:
print
(
bpf_text
)
exit
()
b
=
BPF
(
text
=
bpf_text
)
b
.
attach_kprobe
(
event
=
"blk_account_io_start"
,
fn_name
=
"trace_pid_start"
)
b
.
attach_kprobe
(
event
=
"blk_start_request"
,
fn_name
=
"trace_req_start"
)
b
.
attach_kprobe
(
event
=
"blk_mq_start_request"
,
fn_name
=
"trace_req_start"
)
...
...
tools/tcplife.py
View file @
bb95ef2f
...
...
@@ -58,6 +58,8 @@ parser.add_argument("-L", "--localport",
help
=
"comma-separated list of local ports to trace."
)
parser
.
add_argument
(
"-D"
,
"--remoteport"
,
help
=
"comma-separated list of remote ports to trace."
)
parser
.
add_argument
(
"--ebpf"
,
action
=
"store_true"
,
help
=
argparse
.
SUPPRESS
)
args
=
parser
.
parse_args
()
debug
=
0
...
...
@@ -375,8 +377,10 @@ bpf_text = bpf_text.replace('FILTER_PID', '')
bpf_text
=
bpf_text
.
replace
(
'FILTER_DPORT'
,
''
)
bpf_text
=
bpf_text
.
replace
(
'FILTER_LPORT'
,
''
)
if
debug
:
if
debug
or
args
.
ebpf
:
print
(
bpf_text
)
if
args
.
ebpf
:
exit
()
# event data
TASK_COMM_LEN
=
16
# linux/sched.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