tcpaccept.bt(8)
π tcpaccept.bt π
β¨ NAME β¨
okay so the manual name is tcpaccept.bt (section 8) and it's giving trace TCP passive connections (accept()) π
it uses bpftrace/eBPF under the hood, obsessed π₯
tcpaccept.bt
π SYNOPSIS π
Just type the name, that's the whole spell β¨
tcpaccept.bt
π DESCRIPTION π
okay bestie, this tool traces passive TCP connections (like the ones from an accept() syscall). connect() calls are the active ones, so they're not the vibe here π It's super useful for general troubleshooting when you wanna see what new connections your local server is accepting, iconic π¦
It works by dynamic tracing of the kernel inet_csk_accept() socket function (the one from tcp_prot.accept). β οΈ Heads up, it'll need to be modified to match kernel changes, so don't be shocked if it needs a glow-up later π§
Also, this tool only catches successful TCP accept()s. Connection attempts to closed ports won't show up, so if you need those, you gotta trace them with other functions π
And because it uses BPF, only the root user can run it. No sneaking in π
πΈ REQUIREMENTS πΈ
You need CONFIG_BPF and bpftrace. Non-negotiable, periodt π
π EXAMPLES π
Trace all passive TCP connections (accept()s):
# tcpaccept.bt
π¦ FIELDS π¦
Here's what the output columns mean, no cap:
TIME(s)β Time of the call, inHH:MM:SSformat.PIDβ Process ID.COMMβ Process name.RADDRβ Remote IP address.RPORTβ Remote port.LADDRβ Local IP address.LPORTβ Local portBLβ Current accept backlog vs maximum backlog
π§ OVERHEAD π§
This one traces the kernel inet_csk_accept function and prints output for every single event. How much it costs you depends on your server app, bestie. If it's a web or proxy server accepting many tens of thousands of connections per second, the overhead might be measurable (though honestly still way better than tracing every packet π). If it's less than a thousand a second, the overhead is expected to be negligible β¨ Test it and understand the overhead before you use it, fr fr π«Ά
π SOURCE π
This one's from bpftrace, go check it out π
https://github.com/bpftrace/bpftrace
Also peek in the bpftrace distribution for a companion _examples.txt file with example usage, output, and commentary for this tool. It's giving extra credit π
It's a bpftrace version of the bcc tool of the same name. The bcc tool might have more options and customizations, so if you're craving more, go there π
https://github.com/iovisor/bcc
π OS π
Linux, obviously π§
π STABILITY π
Unstable - in development. It's still cooking, so be gentle π³
π₯ AUTHOR π₯
Brendan Gregg, adapted for bpftrace by Dale Hamel. Iconic duo, literally β
β SEE ALSO β
Check out tcpconnect.bt(8), funccount(8), and tcpdump(8) for more tea β
π«Ά Okay bestie, that's the whole page! Bye bye, from the USER COMMANDS section, dated 2018-10-24, all about tcpaccept.bt(8) πβ¨
π¦ where this page comes from
- alpine 3.24: bpftrace-tools-doc 0.26.1-r0 Β· Apache-2.0
- arch rolling: bpftrace 0.27.0-2 Β· Apache-2.0
- centos-stream 10: bpftrace 0.26.1-1.el10 Β· Apache-2.0
- centos-stream 9: bpftrace 0.26.1-1.el9 Β· ASL 2.0
- debian trixie: bpftrace 0.23.2-1 Β· Apache-2.0
- fedora 43: bpftrace 0.24.0-1.fc43 Β· Apache-2.0
- fedora 43: bpftrace 0.24.2-1.fc43 Β· Apache-2.0
- fedora 44: bpftrace 0.24.2-3.fc44 Β· Apache-2.0
- nixos 26.05: bpftrace 0.25.1
- nixpkgs unstable: bpftrace 0.27.1
- opensuse-leap 16.0: bpftrace-tools 0.23.5-160000.1.2 Β· Apache-2.0
- ubuntu questing: bpftrace 0.23.5-1ubuntu1 Β· Apache-2.0
- ubuntu resolute: bpftrace 0.25.0-1ubuntu1 Β· Apache-2.0
- ubuntu stonking: bpftrace 0.25.0-1ubuntu2 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms