tcpconnect.bt(8)
β¨ NAME β¨
bestie, this is tcpconnect.bt(8) from the System Manager's Manual π
It's a tool that traces TCP active connections (connect()) and it's built on Linux bpftrace/eBPF π₯
πΈ SYNOPSIS πΈ
tcpconnect.bt
π DESCRIPTION π
okay so this tool traces active TCP connections, aka the ones made through a connect() syscall π accept() calls are passive connections, so they're not part of the party π
ββοΈ This is lowkey super useful for general troubleshooting when you wanna see what connections your local server is starting on its own β¨
All connection attempts get traced, even the ones that ultimately fail. no cap, the failures are the tea π«
It works by tracing the kernel tcp_v4_connect() and tcp_v6_connect() functions using dynamic tracing. Heads up: it will need updating if those functions ever change π οΈ
Since this uses BPF, only the root user can use this tool π so no sneaking in as a regular user, periodt π«
π REQUIREMENTS π
You'll need CONFIG_BPF and bpftrace β¨
π¦ EXAMPLES π¦
Trace all active TCP connections:
# tcpconnect.bt
π FIELDS π
Here's what each column is giving:
TIME(s)β the time of the call, in HH:MM:SS format β°PIDβ the process ID πCOMMβ the process name π§SADDRβ the source IP address πSPORTβ the source port πͺDADDRβ the destination IP address π―DPORTβ the destination port π
π₯ OVERHEAD π₯
This traces the kernel tcp_v[46]_connect functions and prints output for each event. Since the rate is generally expected to be low (< 1000/s), the overhead should be negligible, so it's giving chill vibes π BUT if you've got an application making a high rate of connect() calls, like a proxy server, then test and understand this overhead before you use it π bestie, don't skip this step.
π SOURCE π
This is from bpftrace, so go check out the repo at https://github.com/bpftrace/bpftrace π
Also look in the bpftrace distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool π
This is the bpftrace version of the bcc tool with the same name. The bcc tool may provide more options and customizations, so if you need extra features, peek at https://github.com/iovisor/bcc π
π§ OS π§
Linux π§
π STABILITY π
Unstable - in development. so, fair warning, it's still a work in progress π§
π AUTHOR π
Brendan Gregg, adapted for bpftrace by Dale Hamel π«Ά
β¨ SEE ALSO β¨
tcpaccept.bt(8), funccount(8), tcpdump(8) π
Bestie, that's the whole page. It's from USER COMMANDS, dated 2018-11-24, and it's the tcpconnect.bt(8) manual π Slay the troubleshooting, and don't forget to be root ππ
π¦ 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