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
39e13733
Commit
39e13733
authored
Aug 26, 2015
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve code by utilizing trace_readline_fields()
parent
ef2452db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
11 deletions
+5
-11
examples/disksnoop.py
examples/disksnoop.py
+5
-11
No files found.
examples/disksnoop.py
View file @
39e13733
...
@@ -33,16 +33,10 @@ except:
...
@@ -33,16 +33,10 @@ except:
# format output
# format output
while
1
:
while
1
:
try
:
(
task
,
pid
,
cpu
,
flags
,
ts
,
msg
)
=
b
.
trace_readline_fields
()
line
=
trace
.
readline
().
rstrip
()
(
bytes_s
,
bflags_s
,
us_s
)
=
msg
.
split
()
except
KeyboardInterrupt
:
pass
;
exit
()
if
int
(
bflags_s
,
16
)
&
REQ_WRITE
:
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
:
type_s
=
"W"
type_s
=
"W"
elif
bytes_s
==
"0"
:
# see blk_fill_rwbs() for logic
elif
bytes_s
==
"0"
:
# see blk_fill_rwbs() for logic
type_s
=
"M"
type_s
=
"M"
...
@@ -50,4 +44,4 @@ while 1:
...
@@ -50,4 +44,4 @@ while 1:
type_s
=
"R"
type_s
=
"R"
ms
=
float
(
int
(
us_s
,
10
))
/
1000
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
))
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