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
20e23428
Commit
20e23428
authored
Aug 20, 2015
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #153 from brendangregg/master
more examples of b[] syntax, fix func arg passing
parents
d3c27a7d
9421054e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
15 deletions
+12
-15
examples/bitehist.py
examples/bitehist.py
+2
-3
examples/vfsreadlat.py
examples/vfsreadlat.py
+4
-4
tools/pidpersec
tools/pidpersec
+3
-4
tools/vfscount
tools/vfscount
+1
-1
tools/vfsstat
tools/vfsstat
+2
-3
No files found.
examples/bitehist.py
View file @
20e23428
...
@@ -40,7 +40,6 @@ if len(argv) > 1:
...
@@ -40,7 +40,6 @@ if len(argv) > 1:
# load BPF program
# load BPF program
b
=
BPF
(
src_file
=
"bitehist.c"
)
b
=
BPF
(
src_file
=
"bitehist.c"
)
b
.
attach_kprobe
(
event
=
"blk_start_request"
,
fn_name
=
"do_request"
)
b
.
attach_kprobe
(
event
=
"blk_start_request"
,
fn_name
=
"do_request"
)
dist
=
b
.
get_table
(
"dist"
)
dist_max
=
64
dist_max
=
64
# header
# header
...
@@ -63,7 +62,7 @@ def stars(val, val_max, width):
...
@@ -63,7 +62,7 @@ def stars(val, val_max, width):
text
=
text
[:
-
1
]
+
"+"
text
=
text
[:
-
1
]
+
"+"
return
text
return
text
def
print_log2_hist
(
d
,
val_type
):
def
print_log2_hist
(
d
ist
,
val_type
):
idx_max
=
-
1
idx_max
=
-
1
val_max
=
0
val_max
=
0
for
i
in
range
(
1
,
dist_max
+
1
):
for
i
in
range
(
1
,
dist_max
+
1
):
...
@@ -104,6 +103,6 @@ while (1):
...
@@ -104,6 +103,6 @@ while (1):
pass
;
do_exit
=
1
pass
;
do_exit
=
1
print
print
print_log2_hist
(
dist
,
"kbytes"
)
print_log2_hist
(
b
[
"dist"
]
,
"kbytes"
)
if
do_exit
:
if
do_exit
:
exit
()
exit
()
examples/vfsreadlat.py
View file @
20e23428
...
@@ -63,12 +63,12 @@ def stars(val, val_max, width):
...
@@ -63,12 +63,12 @@ def stars(val, val_max, width):
text
=
text
[:
-
1
]
+
"+"
text
=
text
[:
-
1
]
+
"+"
return
text
return
text
def
print_log2_hist
(
d
,
val_type
):
def
print_log2_hist
(
d
ist
,
val_type
):
idx_max
=
-
1
idx_max
=
-
1
val_max
=
0
val_max
=
0
for
i
in
range
(
1
,
dist_max
+
1
):
for
i
in
range
(
1
,
dist_max
+
1
):
try
:
try
:
val
=
b
[
"dist"
]
[
c_int
(
i
)].
value
-
last
[
i
]
val
=
dist
[
c_int
(
i
)].
value
-
last
[
i
]
if
(
val
>
0
):
if
(
val
>
0
):
idx_max
=
i
idx_max
=
i
if
(
val
>
val_max
):
if
(
val
>
val_max
):
...
@@ -83,10 +83,10 @@ def print_log2_hist(d, val_type):
...
@@ -83,10 +83,10 @@ def print_log2_hist(d, val_type):
if
(
low
==
high
):
if
(
low
==
high
):
low
-=
1
low
-=
1
try
:
try
:
val
=
b
[
"dist"
]
[
c_int
(
i
)].
value
-
last
[
i
]
val
=
dist
[
c_int
(
i
)].
value
-
last
[
i
]
print
(
"%8d -> %-8d : %-8d |%-*s|"
%
(
low
,
high
,
val
,
print
(
"%8d -> %-8d : %-8d |%-*s|"
%
(
low
,
high
,
val
,
stars_max
,
stars
(
val
,
val_max
,
stars_max
)))
stars_max
,
stars
(
val
,
val_max
,
stars_max
)))
last
[
i
]
=
b
[
"dist"
]
[
c_int
(
i
)].
value
last
[
i
]
=
dist
[
c_int
(
i
)].
value
except
:
except
:
break
break
...
...
tools/pidpersec
View file @
20e23428
...
@@ -19,10 +19,9 @@ from time import sleep, strftime
...
@@ -19,10 +19,9 @@ from time import sleep, strftime
# load BPF program
# load BPF program
b
=
BPF
(
src_file
=
"pidpersec.c"
)
b
=
BPF
(
src_file
=
"pidpersec.c"
)
b
.
attach_kprobe
(
event
=
"sched_fork"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"sched_fork"
,
fn_name
=
"do_count"
)
stats
=
b
.
get_table
(
"stats"
)
# stat indexes
# stat indexes
S_COUNT
=
1
S_COUNT
=
c_int
(
1
)
# header
# header
print
(
"Tracing... Ctrl-C to end."
)
print
(
"Tracing... Ctrl-C to end."
)
...
@@ -36,5 +35,5 @@ while (1):
...
@@ -36,5 +35,5 @@ while (1):
pass
;
exit
()
pass
;
exit
()
print
(
"%s: PIDs/sec: %d"
%
(
strftime
(
"%H:%M:%S"
),
print
(
"%s: PIDs/sec: %d"
%
(
strftime
(
"%H:%M:%S"
),
(
stats
[
c_int
(
S_COUNT
)
].
value
-
last
)))
(
b
[
"stats"
][
S_COUNT
].
value
-
last
)))
last
=
stats
[
c_int
(
S_COUNT
)
].
value
last
=
b
[
"stats"
][
S_COUNT
].
value
tools/vfscount
View file @
20e23428
...
@@ -57,7 +57,6 @@ b.attach_kprobe(event="vfs_write", fn_name="do_count")
...
@@ -57,7 +57,6 @@ b.attach_kprobe(event="vfs_write", fn_name="do_count")
b
.
attach_kprobe
(
event
=
"vfs_fsync"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_fsync"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_open"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_open"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_create"
,
fn_name
=
"do_count"
)
b
.
attach_kprobe
(
event
=
"vfs_create"
,
fn_name
=
"do_count"
)
counts
=
b
.
get_table
(
"counts"
)
# header
# header
print
(
"Tracing... Ctrl-C to end."
)
print
(
"Tracing... Ctrl-C to end."
)
...
@@ -69,5 +68,6 @@ except KeyboardInterrupt:
...
@@ -69,5 +68,6 @@ except KeyboardInterrupt:
pass
pass
print
(
"
\
n
%-16s %-12s %8s"
%
(
"ADDR"
,
"FUNC"
,
"COUNT"
))
print
(
"
\
n
%-16s %-12s %8s"
%
(
"ADDR"
,
"FUNC"
,
"COUNT"
))
counts
=
b
.
get_table
(
"counts"
)
for
k
,
v
in
sorted
(
counts
.
items
(),
key
=
lambda
counts
:
counts
[
1
].
value
):
for
k
,
v
in
sorted
(
counts
.
items
(),
key
=
lambda
counts
:
counts
[
1
].
value
):
print
(
"%-16x %-12s %8d"
%
(
k
.
ip
,
ksym
(
k
.
ip
),
v
.
value
))
print
(
"%-16x %-12s %8d"
%
(
k
.
ip
,
ksym
(
k
.
ip
),
v
.
value
))
tools/vfsstat
View file @
20e23428
...
@@ -42,7 +42,6 @@ b.attach_kprobe(event="vfs_write", fn_name="do_write")
...
@@ -42,7 +42,6 @@ b.attach_kprobe(event="vfs_write", fn_name="do_write")
b
.
attach_kprobe
(
event
=
"vfs_fsync"
,
fn_name
=
"do_fsync"
)
b
.
attach_kprobe
(
event
=
"vfs_fsync"
,
fn_name
=
"do_fsync"
)
b
.
attach_kprobe
(
event
=
"vfs_open"
,
fn_name
=
"do_open"
)
b
.
attach_kprobe
(
event
=
"vfs_open"
,
fn_name
=
"do_open"
)
b
.
attach_kprobe
(
event
=
"vfs_create"
,
fn_name
=
"do_create"
)
b
.
attach_kprobe
(
event
=
"vfs_create"
,
fn_name
=
"do_create"
)
stats
=
b
.
get_table
(
"stats"
)
# stat column labels and indexes
# stat column labels and indexes
stat_types
=
{
stat_types
=
{
...
@@ -79,9 +78,9 @@ while (1):
...
@@ -79,9 +78,9 @@ while (1):
for
stype
in
stat_types
.
keys
():
for
stype
in
stat_types
.
keys
():
idx
=
stat_types
[
stype
]
idx
=
stat_types
[
stype
]
try
:
try
:
delta
=
stats
[
c_int
(
idx
)].
value
-
last
[
idx
]
delta
=
b
[
"stats"
]
[
c_int
(
idx
)].
value
-
last
[
idx
]
print
(
" %8d"
%
(
delta
/
interval
),
end
=
""
)
print
(
" %8d"
%
(
delta
/
interval
),
end
=
""
)
last
[
idx
]
=
stats
[
c_int
(
idx
)].
value
last
[
idx
]
=
b
[
"stats"
]
[
c_int
(
idx
)].
value
except
:
except
:
print
(
" %8d"
%
0
,
end
=
""
)
print
(
" %8d"
%
0
,
end
=
""
)
print
(
""
)
print
(
""
)
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