tcpaccept(8)
π tcpaccept(8) π
System Manager's Manual π
β¨ NAME β¨
tcpaccept β okay so this one traces TCP passive connections (the accept() ones) π¦ It's Linux-only and uses eBPF/bcc π
π§ SYNOPSIS β¨
tcpaccept [-h] [-T] [-t] [-p PID] [-P PORTS] [-4 | -6] [--cgroupmap
MAPPATH] [--mntnsmap MAPPATH]
π DESCRIPTION β¨
Bestie, this tool traces passive TCP connections, meaning the ones that come in through an accept() syscall. (connect() is the active side, so it's not included π) It's giving very useful for general troubleshooting, because you can see every new connection your local server is accepting π
This works by dynamic tracing of the kernel inet_csk_accept() socket function (from tcp_prot.accept). It'll need to be modified to match kernel changes, so keep that in mind π§
Only successful TCP accept()s get traced. Connection attempts to closed ports won't show up here π (you can trace those with other functions, though).
Since this uses BPF, only the root user can use this tool. No cap, that's a hard rule π
πΈ REQUIREMENTS β¨
You'll need CONFIG_BPF and bcc π
π OPTIONS β¨
-hβ print the usage message π-Tβ include a time column on the output, formatted asHH:MM:SSβ°-tβ include a timestamp column π°οΈ-p PIDβ trace only this process ID (filtered in-kernel) π―-P PORTSβ trace only these local ports, given as a comma-separated list (filtered in-kernel) π-4β trace the IPv4 family only π-6β trace the IPv6 family only π--cgroupmap MAPPATHβ trace only the cgroups in this BPF map (filtered in-kernel) π«§--mntnsmap MAPPATHβ trace only the mount namespaces in this BPF map (filtered in-kernel) π§©
π¦ EXAMPLES β¨
Trace all passive TCP connections (accept()s):
# tcpaccept
Trace all TCP accepts, and include timestamps:
# tcpaccept -t
Trace connections to local ports 80 and 81 only:
# tcpaccept -P 80,81
Trace PID 181 only:
# tcpaccept -p 181
Trace IPv4 family only:
# tcpaccept -4
Trace IPv6 family only:
# tcpaccept -6
Trace a set of cgroups only (see special_filtering.md from the bcc sources for more details):
# tcpaccept --cgroupmap /sys/fs/bpf/test01
π§Ύ FIELDS β¨
TIMEβ time of the event, inHH:MM:SSformat β±οΈTIME(s)β time of the event, in seconds πPIDβ process ID πCOMMβ process name π·οΈIPβ IP address family (4 or 6) πRADDRβ remote IP address πRPORTβ remote port πͺLADDRβ local IP address πLPORTβ local port π
π’ OVERHEAD β¨
This traces the kernel inet_csk_accept function and prints output for each event. How much it costs depends on your server app. If it's a web or proxy server accepting many tens of thousands of connections per second, the overhead can be measurable (still way better than tracing every packet, though π). If it's under a thousand a second, the overhead is expected to be negligible. Test it and understand the overhead before you use it in real life π«Ά
π· SOURCE β¨
This is from bcc π
https://github.com/iovisor/bcc
Also look in the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool π
π» OS β¨
Linux π§
π§ͺ STABILITY β¨
Unstable β still in development π§
π©βπ» AUTHOR β¨
Brendan Gregg π
π SEE ALSO β¨
tcptracer(8), tcpconnect(8), funccount(8), tcpdump(8) π
Sign-off time! π This page is from USER COMMANDS, dated 2020-02-20, and it's the tcpaccept(8) page. Now go trace some accepts, bestie π β¨π«Ά
π¦ where this page comes from
- alpine 3.24: bcc-doc 0.36.1-r1 Β· Apache-2.0
- nixpkgs unstable: bcc 0.37.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms