tcpconnect.bt(8)
π tcpconnect.bt π
ok so bestie, welcome to tcpconnect.bt from section 8 of the System Manager's Manual β yes, the big-girl admin section, we love her π
β¨ NAME β¨
tcpconnect.bt β trace TCP active connections (connect()), powered by Linux bpftrace/eBPF π
π¦ SYNOPSIS π¦
tcpconnect.bt
no args, no flags, no drama. she just runs π
π DESCRIPTION π
so basically this tool traces active TCP connections β think the ones you get from a connect() syscall π«Ά. (accept() connections are the passive ones, so those are NOT it, bestie, they're a different vibe entirely.)
this is lowkey perfect for general troubleshooting when you wanna see what connections your local server is initiating. like, who is she calling?? π
every single connection attempt gets traced, even if it ultimately fails. no cap. the failures are still getting clocked π
how does the magic happen? it works by tracing the kernel tcp_v4_connect() and tcp_v6_connect() functions using dynamic tracing β which means if those kernel functions ever change, this tool will need updating to match them. so keep an eye out, she's sensitive π§
and because this uses BPF, only the root user can use this tool. sorry babe, that's just the rules π
πΈ REQUIREMENTS πΈ
CONFIG_BPFbpftrace
both of them. periodt π
β EXAMPLES β
trace all active TCP connections:
# tcpconnect.bt
slay. that's the whole command. iconic behavior honestly π₯
π FIELDS π
here's the tea on every column she's gonna hand you:
TIME(s)β the time of the call, inHH:MM:SSformat β°PIDβ process IDCOMMβ process nameSADDRβ source IP addressSPORTβ source portDADDRβ destination IP addressDPORTβ destination port
look at all those little letters, it's giving β¨ organized β¨
π₯ OVERHEAD π₯
so, the deal: this traces the kernel tcp_v[46]_connect functions and prints output for each event.
is that scary? nope π«Ά because the rate of this is generally expected to be low β like < 1000/s β so the overhead is also expected to be negligible.
BUT β and this is important, bestie, don't skip this part π β if you've got an application calling a high rate of connect()s, such as a proxy server, then you need to test and understand this overhead before use. do not just rawdog it into prod, I'm begging π
π SOURCE π
this is from bpftrace:
https://github.com/iovisor/bpftrace
also, go look in the bpftrace distribution for a companion _examples.txt file β it's got example usage, output, and commentary for this tool π (basically the director's commentary track, we're obsessed)
and pssst β this is a bpftrace version of the bcc tool of the same name. the bcc tool may provide more options and customizations, so if you want more knobs to turn:
https://github.com/iovisor/bcc
π OS π
Linux π§ (obviously, she's not doing all this on anything else)
π STABILITY π
Unstable - in development.
translation: she's still in her growing era, handle with care π±
π AUTHOR π
Brendan Gregg, adapted for bpftrace by Dale Hamel
legends. both of them. thank you for your service π«‘π
π SEE ALSO π
(the whole friend group, go say hi)
ok bye bestie, go trace some connects π¦π β¨
this one's from the USER COMMANDS corner of the manual, dated 2018-11-24, and it lives at tcpconnect.bt(8) β mwah, xoxo π
π¦ where this page comes from
- debian bookworm: bpftrace 0.17.0-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms