Commit fc50799b authored by dpayne's avatar dpayne

Moving duration to primary argument for tcpconnlat. Also updating docs for tcpconnlat to match.

parent 7b7e34a2
......@@ -2,7 +2,7 @@
.SH NAME
tcpconnlat \- Trace TCP active connection latency. Uses Linux eBPF/bcc.
.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
This tool traces active TCP connections
(eg, via a connect() syscall), and shows the latency (time) for the connection
......@@ -31,14 +31,11 @@ Include a timestamp column.
\-p PID
Trace this process ID only (filtered in-kernel).
.TP
\-m MIN_NS
Minimum duration to trace, in milliseconds.
.TP
\-u MIN_US
Minimum duration to trace, in microseconds.
.TP
\-v
Print the resulting BPF program, for debugging purposes.
.TP
min_ns
Minimum duration to trace, in milliseconds.
.SH EXAMPLES
.TP
Trace all active TCP connections, and show connection latency (SYN->response round trip):
......@@ -55,7 +52,7 @@ Trace PID 181 only:
.TP
Trace connects with latency longer than 10 ms:
#
.B tcpconnlat \-m 10
.B tcpconnlat 10
.TP
Print the BPF program:
#
......
......@@ -21,11 +21,22 @@ from struct import pack
import argparse
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
examples = """examples:
./tcpconnlat # trace all TCP connect()s
./tcpconnlat -m 1 # only show results slower than 1 ms
./tcpconnlat -u 100 # only show results slower than 100 microseconds
./tcpconnlat 1 # trace connection latency slower than 1 ms
./tcpconnlat 0.1 # trace connection latency slower than 100 us
./tcpconnlat -t # include timestamps
./tcpconnlat -p 181 # only trace PID 181
"""
......@@ -37,18 +48,16 @@ parser.add_argument("-t", "--timestamp", action="store_true",
help="include timestamp on output")
parser.add_argument("-p", "--pid",
help="trace this PID only")
parser.add_argument("-m", "--min-ms", type=float, dest="min_ms",
help="minimum latency filter (ms)")
parser.add_argument("-u", "--min-us", type=float, dest="min_us",
help="minimum latency filter (us)")
parser.add_argument("duration_ms", nargs="?", default=0,
type=positive_float,
help="minimum duration to trace (ms)")
parser.add_argument("-v", "--verbose", action="store_true",
help="print the BPF program for debugging purposes")
args = parser.parse_args()
if args.min_ms:
duration_us = int(args.min_ms * 1000)
elif args.min_us:
duration_us = int(args.min_us)
if args.duration_ms:
# support fractions but round to nearest microsecond
duration_us = int(args.duration_ms * 1000)
else:
duration_us = 0 # default is show all
......
......@@ -47,6 +47,6 @@ examples:
./tcpconnlat # trace all TCP connect()s
./tcpconnlat -t # include timestamps
./tcpconnlat -p 181 # only trace PID 181
./tcpconnlat -m 1 # only show connects longer than 1 ms
./tcpconnlat -u 100 # only show connects longer than 100 us
./tcpconnlat 1 # only show connects longer than 1 ms
./tcpconnlat 0.1 # only show connects longer than 100 us
./tcpconnlat -v # Show the BPF program
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment