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
fc50799b
Commit
fc50799b
authored
Jan 18, 2018
by
dpayne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving duration to primary argument for tcpconnlat. Also updating docs for tcpconnlat to match.
parent
7b7e34a2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
20 deletions
+26
-20
man/man8/tcpconnlat.8
man/man8/tcpconnlat.8
+5
-8
tools/tcpconnlat.py
tools/tcpconnlat.py
+19
-10
tools/tcpconnlat_example.txt
tools/tcpconnlat_example.txt
+2
-2
No files found.
man/man8/tcpconnlat.8
View file @
fc50799b
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
.SH NAME
.SH NAME
tcpconnlat \- Trace TCP active connection latency. Uses Linux eBPF/bcc.
tcpconnlat \- Trace TCP active connection latency. Uses Linux eBPF/bcc.
.SH SYNOPSIS
.SH SYNOPSIS
.B tcpconnlat [\-h] [\-t] [\-p PID] [-
m MIN_MS] [-u MIN_US] [-v
]
.B tcpconnlat [\-h] [\-t] [\-p PID] [-
v] [min_ms
]
.SH DESCRIPTION
.SH DESCRIPTION
This tool traces active TCP connections
This tool traces active TCP connections
(eg, via a connect() syscall), and shows the latency (time) for the connection
(eg, via a connect() syscall), and shows the latency (time) for the connection
...
@@ -31,14 +31,11 @@ Include a timestamp column.
...
@@ -31,14 +31,11 @@ Include a timestamp column.
\-p PID
\-p PID
Trace this process ID only (filtered in-kernel).
Trace this process ID only (filtered in-kernel).
.TP
.TP
\-m MIN_NS
Minimum duration to trace, in milliseconds.
.TP
\-u MIN_US
Minimum duration to trace, in microseconds.
.TP
\-v
\-v
Print the resulting BPF program, for debugging purposes.
Print the resulting BPF program, for debugging purposes.
.TP
min_ns
Minimum duration to trace, in milliseconds.
.SH EXAMPLES
.SH EXAMPLES
.TP
.TP
Trace all active TCP connections, and show connection latency (SYN->response round trip):
Trace all active TCP connections, and show connection latency (SYN->response round trip):
...
@@ -55,7 +52,7 @@ Trace PID 181 only:
...
@@ -55,7 +52,7 @@ Trace PID 181 only:
.TP
.TP
Trace connects with latency longer than 10 ms:
Trace connects with latency longer than 10 ms:
#
#
.B tcpconnlat
\-m
10
.B tcpconnlat 10
.TP
.TP
Print the BPF program:
Print the BPF program:
#
#
...
...
tools/tcpconnlat.py
View file @
fc50799b
...
@@ -21,11 +21,22 @@ from struct import pack
...
@@ -21,11 +21,22 @@ from struct import pack
import
argparse
import
argparse
import
ctypes
as
ct
import
ctypes
as
ct
# arg validation
def
positive_float
(
val
):
try
:
ival
=
float
(
val
)
except
ValueError
:
raise
argparse
.
ArgumentTypeError
(
"must be a float"
)
if
ival
<
0
:
raise
argparse
.
ArgumentTypeError
(
"must be positive"
)
return
ival
# arguments
# arguments
examples
=
"""examples:
examples
=
"""examples:
./tcpconnlat # trace all TCP connect()s
./tcpconnlat # trace all TCP connect()s
./tcpconnlat
-m 1 # only show results
slower than 1 ms
./tcpconnlat
1 # trace connection latency
slower than 1 ms
./tcpconnlat
-u 100 # only show results slower than 100 microsecond
s
./tcpconnlat
0.1 # trace connection latency slower than 100 u
s
./tcpconnlat -t # include timestamps
./tcpconnlat -t # include timestamps
./tcpconnlat -p 181 # only trace PID 181
./tcpconnlat -p 181 # only trace PID 181
"""
"""
...
@@ -37,18 +48,16 @@ parser.add_argument("-t", "--timestamp", action="store_true",
...
@@ -37,18 +48,16 @@ parser.add_argument("-t", "--timestamp", action="store_true",
help
=
"include timestamp on output"
)
help
=
"include timestamp on output"
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
parser
.
add_argument
(
"-p"
,
"--pid"
,
help
=
"trace this PID only"
)
help
=
"trace this PID only"
)
parser
.
add_argument
(
"-m"
,
"--min-ms"
,
type
=
float
,
dest
=
"min_ms"
,
parser
.
add_argument
(
"duration_ms"
,
nargs
=
"?"
,
default
=
0
,
help
=
"minimum latency filter (ms)"
)
type
=
positive_float
,
parser
.
add_argument
(
"-u"
,
"--min-us"
,
type
=
float
,
dest
=
"min_us"
,
help
=
"minimum duration to trace (ms)"
)
help
=
"minimum latency filter (us)"
)
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
help
=
"print the BPF program for debugging purposes"
)
help
=
"print the BPF program for debugging purposes"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
min_ms
:
if
args
.
duration_ms
:
duration_us
=
int
(
args
.
min_ms
*
1000
)
# support fractions but round to nearest microsecond
elif
args
.
min_us
:
duration_us
=
int
(
args
.
duration_ms
*
1000
)
duration_us
=
int
(
args
.
min_us
)
else
:
else
:
duration_us
=
0
# default is show all
duration_us
=
0
# default is show all
...
...
tools/tcpconnlat_example.txt
View file @
fc50799b
...
@@ -47,6 +47,6 @@ examples:
...
@@ -47,6 +47,6 @@ examples:
./tcpconnlat # trace all TCP connect()s
./tcpconnlat # trace all TCP connect()s
./tcpconnlat -t # include timestamps
./tcpconnlat -t # include timestamps
./tcpconnlat -p 181 # only trace PID 181
./tcpconnlat -p 181 # only trace PID 181
./tcpconnlat
-m 1
# only show connects longer than 1 ms
./tcpconnlat
1
# only show connects longer than 1 ms
./tcpconnlat
-u 100
# only show connects longer than 100 us
./tcpconnlat
0.1
# only show connects longer than 100 us
./tcpconnlat -v # Show the BPF program
./tcpconnlat -v # Show the BPF program
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