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
85208ec1
Commit
85208ec1
authored
9 years ago
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #167 from brendangregg/master
improve examples using new features
parents
0c7ab873
39e13733
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
30 deletions
+15
-30
examples/bitehist.py
examples/bitehist.py
+3
-6
examples/disksnoop.py
examples/disksnoop.py
+5
-11
examples/vfsreadlat.py
examples/vfsreadlat.py
+3
-6
tools/pidpersec
tools/pidpersec
+1
-2
tools/vfsstat
tools/vfsstat
+3
-5
No files found.
examples/bitehist.py
View file @
85208ec1
...
...
@@ -44,9 +44,6 @@ dist_max = 64
# header
print
(
"Tracing... Hit Ctrl-C to end."
)
last
=
{}
for
i
in
range
(
1
,
dist_max
+
1
):
last
[
i
]
=
0
# functions
stars_max
=
38
...
...
@@ -67,7 +64,7 @@ def print_log2_hist(dist, val_type):
val_max
=
0
for
i
in
range
(
1
,
dist_max
+
1
):
try
:
val
=
dist
[
c_int
(
i
)].
value
-
last
[
i
]
val
=
dist
[
c_int
(
i
)].
value
if
(
val
>
0
):
idx_max
=
i
if
(
val
>
val_max
):
...
...
@@ -82,10 +79,9 @@ def print_log2_hist(dist, val_type):
if
(
low
==
high
):
low
-=
1
try
:
val
=
dist
[
c_int
(
i
)].
value
-
last
[
i
]
val
=
dist
[
c_int
(
i
)].
value
print
(
"%8d -> %-8d : %-8d |%-*s|"
%
(
low
,
high
,
val
,
stars_max
,
stars
(
val
,
val_max
,
stars_max
)))
last
[
i
]
=
dist
[
c_int
(
i
)].
value
except
:
break
...
...
@@ -104,5 +100,6 @@ while (1):
print
print_log2_hist
(
b
[
"dist"
],
"kbytes"
)
b
[
"dist"
].
clear
()
if
do_exit
:
exit
()
This diff is collapsed.
Click to expand it.
examples/disksnoop.py
View file @
85208ec1
...
...
@@ -33,16 +33,10 @@ except:
# format output
while
1
:
try
:
line
=
trace
.
readline
().
rstrip
()
except
KeyboardInterrupt
:
pass
;
exit
()
prolog
,
time_s
,
colon
,
bytes_s
,
flags_s
,
us_s
=
\
line
.
rsplit
(
" "
,
5
)
time_s
=
time_s
[:
-
1
]
# strip trailing ":"
flags
=
int
(
flags_s
,
16
)
if
flags
&
REQ_WRITE
:
(
task
,
pid
,
cpu
,
flags
,
ts
,
msg
)
=
b
.
trace_readline_fields
()
(
bytes_s
,
bflags_s
,
us_s
)
=
msg
.
split
()
if
int
(
bflags_s
,
16
)
&
REQ_WRITE
:
type_s
=
"W"
elif
bytes_s
==
"0"
:
# see blk_fill_rwbs() for logic
type_s
=
"M"
...
...
@@ -50,4 +44,4 @@ while 1:
type_s
=
"R"
ms
=
float
(
int
(
us_s
,
10
))
/
1000
print
(
"%-18
s %-2s %-7s %8.2f"
%
(
time_
s
,
type_s
,
bytes_s
,
ms
))
print
(
"%-18
.9f %-2s %-7s %8.2f"
%
(
t
s
,
type_s
,
bytes_s
,
ms
))
This diff is collapsed.
Click to expand it.
examples/vfsreadlat.py
View file @
85208ec1
...
...
@@ -45,9 +45,6 @@ dist_max = 64
# header
print
(
"Tracing... Hit Ctrl-C to end."
)
last
=
{}
for
i
in
range
(
1
,
dist_max
+
1
):
last
[
i
]
=
0
# functions
stars_max
=
38
...
...
@@ -68,7 +65,7 @@ def print_log2_hist(dist, val_type):
val_max
=
0
for
i
in
range
(
1
,
dist_max
+
1
):
try
:
val
=
dist
[
c_int
(
i
)].
value
-
last
[
i
]
val
=
dist
[
c_int
(
i
)].
value
if
(
val
>
0
):
idx_max
=
i
if
(
val
>
val_max
):
...
...
@@ -83,10 +80,9 @@ def print_log2_hist(dist, val_type):
if
(
low
==
high
):
low
-=
1
try
:
val
=
dist
[
c_int
(
i
)].
value
-
last
[
i
]
val
=
dist
[
c_int
(
i
)].
value
print
(
"%8d -> %-8d : %-8d |%-*s|"
%
(
low
,
high
,
val
,
stars_max
,
stars
(
val
,
val_max
,
stars_max
)))
last
[
i
]
=
dist
[
c_int
(
i
)].
value
except
:
break
...
...
@@ -105,5 +101,6 @@ while (1):
print
print_log2_hist
(
b
[
"dist"
],
"usecs"
)
b
[
"dist"
].
clear
()
if
do_exit
:
exit
()
This diff is collapsed.
Click to expand it.
tools/pidpersec
View file @
85208ec1
...
...
@@ -28,7 +28,6 @@ S_COUNT = c_int(1)
print
(
"Tracing... Ctrl-C to end."
)
# output
last
=
0
while
(
1
):
try
:
sleep
(
1
)
...
...
@@ -36,5 +35,5 @@ while (1):
exit
()
print
(
"%s: PIDs/sec: %d"
%
(
strftime
(
"%H:%M:%S"
),
(
b
[
"stats"
][
S_COUNT
].
value
)
))
b
[
"stats"
][
S_COUNT
].
value
))
b
[
"stats"
].
clear
()
This diff is collapsed.
Click to expand it.
tools/vfsstat
View file @
85208ec1
...
...
@@ -54,11 +54,9 @@ stat_types = {
# header
print
(
"%-8s "
%
"TIME"
,
end
=
""
)
last
=
{}
for
stype
in
stat_types
.
keys
():
print
(
" %8s"
%
(
stype
+
"/s"
),
end
=
""
)
idx
=
stat_types
[
stype
]
last
[
idx
]
=
0
print
(
""
)
# output
...
...
@@ -78,9 +76,9 @@ while (1):
for
stype
in
stat_types
.
keys
():
idx
=
stat_types
[
stype
]
try
:
delta
=
b
[
"stats"
][
c_int
(
idx
)].
value
-
last
[
idx
]
print
(
" %8d"
%
(
delta
/
interval
),
end
=
""
)
last
[
idx
]
=
b
[
"stats"
][
c_int
(
idx
)].
value
val
=
b
[
"stats"
][
c_int
(
idx
)].
value
/
interval
print
(
" %8d"
%
val
,
end
=
""
)
except
:
print
(
" %8d"
%
0
,
end
=
""
)
b
[
"stats"
].
clear
()
print
(
""
)
This diff is collapsed.
Click to expand it.
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