tcpaccept(8) System Manager's Manual tcpaccept(8)

# [NAME](#NAME)

tcpaccept - Trace TCP passive connections (accept()). Uses Linux eBPF/bcc.

# [SYNOPSIS](#SYNOPSIS)

**tcpaccept \[-h] \[-T] \[-t] \[-p PID] \[-P PORTS] \[-4 | -6] \[--cgroupmap MAPPATH] \[--mntnsmap MAPPATH]**

# [DESCRIPTION](#DESCRIPTION)

This tool traces passive TCP connections (eg, via an accept() syscall; connect() are active connections). This can be useful for general troubleshooting to see what new connections the local server is accepting.

This uses dynamic tracing of the kernel inet\_csk\_accept() socket function (from tcp\_prot.accept), and will need to be modified to match kernel changes.

This tool only traces successful TCP accept()s. Connection attempts to closed ports will not be shown (those can be traced via other functions).

Since this uses BPF, only the root user can use this tool.

# [REQUIREMENTS](#REQUIREMENTS)

CONFIG\_BPF and bcc.

# [OPTIONS](#OPTIONS)

[-h](#h)

Print usage message.

[-T](#T)

Include a time column on output (HH:MM:SS).

[-t](#t)

Include a timestamp column.

[-p PID](#p)

Trace this process ID only (filtered in-kernel).

[-P PORTS](#P)

Comma-separated list of local ports to trace (filtered in-kernel).

-4

Trace IPv4 family only.

-6

Trace IPv6 family only.

[--cgroupmap MAPPATH](#cgroupmap)

Trace cgroups in this BPF map only (filtered in-kernel).

[--mntnsmap MAPPATH](#mntnsmap)

Trace mount namespaces in this BPF map only (filtered in-kernel).

# [EXAMPLES](#EXAMPLES)

[Trace all passive TCP connections (accept()s):](#Trace)

\# **tcpaccept**

[Trace all TCP accepts, and include timestamps:](#Trace~2)

\# **tcpaccept -t**

[Trace connections to local ports 80 and 81 only:](#Trace~3)

\# **tcpaccept -P 80,81**

[Trace PID 181 only:](#Trace~4)

\# **tcpaccept -p 181**

[Trace IPv4 family only:](#Trace~5)

\# **tcpaccept -4**

[Trace IPv6 family only:](#Trace~6)

\# **tcpaccept -6**

[Trace a set of cgroups only (see special\_filtering.md from bcc sources for more details):](#Trace~7)

\# **tcpaccept --cgroupmap /sys/fs/bpf/test01**

# [FIELDS](#FIELDS)

[TIME](#TIME)

Time of the event, in HH:MM:SS format.

[TIME(s)](#TIME%28s%29)

Time of the event, in seconds.

[PID](#PID)

Process ID

[COMM](#COMM)

Process name

[IP](#IP)

IP address family (4 or 6)

[RADDR](#RADDR)

Remote IP address.

[RPORT](#RPORT)

Remote port

[LADDR](#LADDR)

Local IP address.

[LPORT](#LPORT)

Local port

# [OVERHEAD](#OVERHEAD)

This traces the kernel inet\_csk\_accept function and prints output for each event. The rate of this depends on your server application. If it is a web or proxy server accepting many tens of thousands of connections per second, then the overhead of this tool may be measurable (although, still a lot better than tracing every packet). If it is less than a thousand a second, then the overhead is expected to be negligible. Test and understand this overhead before use.

# [SOURCE](#SOURCE)

This is from bcc.

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion \_examples.txt file containing example usage, output, and commentary for this tool.

# [OS](#OS)

Linux

# [STABILITY](#STABILITY)

Unstable - in development.

# [AUTHOR](#AUTHOR)

Brendan Gregg

# [SEE ALSO](#SEE_ALSO)

[tcptracer(8)](/man/enterprise-packages/bcc/tcptracer.8), [tcpconnect(8)](/man/enterprise-packages/bcc/tcpconnect.8), [funccount(8)](/man/enterprise-packages/bcc/funccount.8), [tcpdump(8)](/man/enterprise-packages/bcc/tcpdump.8)

2020-02-20 USER COMMANDS

---

Document: tcpaccept(8) from bcc 0.37.0-r2 (Chainguard OS)
Source: https://github.com/iovisor/bcc
