tcpconnect.bt(8)

πŸ“¦
version 0.27.0 Β· 3 versions
  • 0.27.0 Β· alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.14.0 Β· ubuntu jammy
  • 0.20.2 Β· ubuntu noble
, in alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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 πŸ‘‘πŸ’