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
40b881c5
Commit
40b881c5
authored
Mar 05, 2017
by
4ast
Committed by
GitHub
Mar 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1023 from dneiter/filetop_sort
filetop: support specifying sort column via cmdline argument
parents
956ca1c8
caa38c55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
10 deletions
+21
-10
man/man8/filetop.8
man/man8/filetop.8
+9
-5
tools/filetop.py
tools/filetop.py
+5
-1
tools/filetop_example.txt
tools/filetop_example.txt
+7
-4
No files found.
man/man8/filetop.8
View file @
40b881c5
...
@@ -2,14 +2,15 @@
...
@@ -2,14 +2,15 @@
.SH NAME
.SH NAME
filetop \- File reads and writes by filename and process. Top for files.
filetop \- File reads and writes by filename and process. Top for files.
.SH SYNOPSIS
.SH SYNOPSIS
.B filetop [\-h] [\-C] [\-r MAXROWS] [\-p PID] [interval] [count]
.B filetop [\-h] [\-C] [\-r MAXROWS] [\-
s {reads,writes,rbytes,wbytes}] [\-
p PID] [interval] [count]
.SH DESCRIPTION
.SH DESCRIPTION
This is top for files.
This is top for files.
This traces file reads and writes, and prints a per-file summary every
This traces file reads and writes, and prints a per-file summary every interval
interval (by default, 1 second). The summary is sorted on the highest read
(by default, 1 second). By default the summary is sorted on the highest read
throughput (Kbytes). By default only IO on regular files is shown. The -a
throughput (Kbytes). Sorting order can be changed via -s option. By default only
option will list all file types (sokets, FIFOs, etc).
IO on regular files is shown. The -a option will list all file types (sokets,
FIFOs, etc).
This uses in-kernel eBPF maps to store per process summaries for efficiency.
This uses in-kernel eBPF maps to store per process summaries for efficiency.
...
@@ -39,6 +40,9 @@ Don't clear the screen.
...
@@ -39,6 +40,9 @@ Don't clear the screen.
\-r MAXROWS
\-r MAXROWS
Maximum number of rows to print. Default is 20.
Maximum number of rows to print. Default is 20.
.TP
.TP
\-s {reads,writes,rbytes,wbytes}
Sort column. Default is rbytes (read throughput).
.TP
\-p PID
\-p PID
Trace this PID only.
Trace this PID only.
.TP
.TP
...
...
tools/filetop.py
View file @
40b881c5
...
@@ -38,6 +38,9 @@ parser.add_argument("-C", "--noclear", action="store_true",
...
@@ -38,6 +38,9 @@ parser.add_argument("-C", "--noclear", action="store_true",
help
=
"don't clear the screen"
)
help
=
"don't clear the screen"
)
parser
.
add_argument
(
"-r"
,
"--maxrows"
,
default
=
20
,
parser
.
add_argument
(
"-r"
,
"--maxrows"
,
default
=
20
,
help
=
"maximum rows to print, default 20"
)
help
=
"maximum rows to print, default 20"
)
parser
.
add_argument
(
"-s"
,
"--sort"
,
default
=
"rbytes"
,
choices
=
[
"reads"
,
"writes"
,
"rbytes"
,
"wbytes"
],
help
=
"sort column, default rbytes"
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
type
=
int
,
metavar
=
"PID"
,
dest
=
"tgid"
,
parser
.
add_argument
(
"-p"
,
"--pid"
,
type
=
int
,
metavar
=
"PID"
,
dest
=
"tgid"
,
help
=
"trace this PID only"
)
help
=
"trace this PID only"
)
parser
.
add_argument
(
"interval"
,
nargs
=
"?"
,
default
=
1
,
parser
.
add_argument
(
"interval"
,
nargs
=
"?"
,
default
=
1
,
...
@@ -184,7 +187,8 @@ while 1:
...
@@ -184,7 +187,8 @@ while 1:
counts
=
b
.
get_table
(
"counts"
)
counts
=
b
.
get_table
(
"counts"
)
line
=
0
line
=
0
for
k
,
v
in
reversed
(
sorted
(
counts
.
items
(),
for
k
,
v
in
reversed
(
sorted
(
counts
.
items
(),
key
=
lambda
counts
:
counts
[
1
].
rbytes
)):
key
=
lambda
counts
:
getattr
(
counts
[
1
],
args
.
sort
))):
name
=
k
.
name
.
decode
()
name
=
k
.
name
.
decode
()
if
k
.
name_len
>
DNAME_INLINE_LEN
:
if
k
.
name_len
>
DNAME_INLINE_LEN
:
name
=
name
[:
-
3
]
+
"..."
name
=
name
[:
-
3
]
+
"..."
...
...
tools/filetop_example.txt
View file @
40b881c5
...
@@ -29,10 +29,11 @@ PID COMM READS WRITES R_Kb W_Kb T FILE
...
@@ -29,10 +29,11 @@ PID COMM READS WRITES R_Kb W_Kb T FILE
26628 ld 12 0 52 0 R swap.o
26628 ld 12 0 52 0 R swap.o
[...]
[...]
This shows various files read and written during a Linux kernel build. The
This shows various files read and written during a Linux kernel build. By
output is sorted by the total read size in Kbytes (R_Kb). This is instrumenting
default the output is sorted by the total read size in Kbytes (R_Kb). Sorting
at the VFS interface, so this is reads and writes that may return entirely
order can be changed via -s option. This is instrumenting at the VFS interface,
from the file system cache (page cache).
so this is reads and writes that may return entirely from the file system cache
(page cache).
While not printed, the average read and write size can be calculated by
While not printed, the average read and write size can be calculated by
dividing R_Kb by READS, and the same for writes.
dividing R_Kb by READS, and the same for writes.
...
@@ -146,6 +147,8 @@ optional arguments:
...
@@ -146,6 +147,8 @@ optional arguments:
-C, --noclear don't clear the screen
-C, --noclear don't clear the screen
-r MAXROWS, --maxrows MAXROWS
-r MAXROWS, --maxrows MAXROWS
maximum rows to print, default 20
maximum rows to print, default 20
-s {reads,writes,rbytes,wbytes}, --sort {reads,writes,rbytes,wbytes}
sort column, default rbytes
-p PID, --pid PID trace this PID only
-p PID, --pid PID trace this PID only
examples:
examples:
...
...
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