tcplife-go

command module
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tcplife-go

CI

A single-binary, CO-RE eBPF tool that reports TCP session lifetime/throughput and UDP flows, in the spirit of BCC's tcplife — but with a live, interactive terminal UI.

tcplife-go screenshot

Features

  • Live TUI (default when stdout is a TTY): grouped/aggregated table with realtime byte counters for open connections, on-the-fly grouping, sorting, filtering, collapsing and pause.
  • Plain streaming (when stdout is not a TTY): classic tcplife-style one-line-per-session output, easy to pipe or log.
  • TCP session lifetime, addresses, PID, ps aux-style command line, TCP state and RX/TX byte counts; realtime RX/s and TX/s rates for active connections.
  • UDP flows keyed by 4-tuple, so an unconnected server socket shows one row per peer.
  • Pure CO-RE (vmlinux.h from BTF): no kernel headers required at runtime.
  • Single static Go binary; the compiled BPF object is embedded.

Requirements

  • Linux with BTF (/sys/kernel/btf/vmlinux) — CO-RE relocations need it.
  • Root, or CAP_BPF + CAP_PERFMON (raise ulimit -l unlimited if the kernel lacks memcg-based BPF memory accounting).
  • Kernel 5.8+ for the realtime counters and UDP flows; older kernels still work in close-only mode.
  • To build: Go 1.25+, clang, and bpftool.

Build

git clone https://github.com/burik666/tcplife-go
cd tcplife-go
make build          # regenerates vmlinux.h from your kernel and compiles bpf.c
sudo ./bin/tcplife-go

go install github.com/burik666/tcplife-go@latest also works, but it embeds the BPF object committed to the repo rather than building one for your kernel: no clang/bpftool needed, but it only runs on BTF-enabled kernels. If it fails to load, build from source with make build.

Usage

tcplife-go [-time-format format] [-version]
Flag Default Description
-time-format time Event-time format: a named layout (time, datetime, date, rfc3339, rfc3339nano, kitchen, stamp, unixdate, rfc1123, ...) or any custom Go layout such as 2006-01-02 15:04:05.
-version Print version and exit.

When stdout is a terminal the TUI starts; otherwise the tool streams plain lines and is meant to be piped or redirected, e.g.:

sudo ./bin/tcplife-go | tee tcplife.log

TUI keybindings

Key Action
/ Focus the filter field (full regexp over PID, command line, addresses and TCP state; Esc clears)
t Cycle protocol filter: All → TCP → UDP
g Choose grouping
s Choose sort field
r Toggle sort direction (ascending / descending)
space Collapse / expand the selected group
+ / - Expand / collapse all groups
p Pause / resume live refresh
c Clear all collected sessions
← / → Scroll the table horizontally (COMMAND is never clipped)
q / Ctrl-C Quit

Columns: TIME DURATION PID PROTO LADDR RADDR RX TX RX/s TX/s STATE COMMAND. The header marks the active sort column(s) with ↑/↓.

License

MIT © 2026 Andrey Burov

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL