blob: 1089a581285acd36fcbb47da907da84860675ce8 [file] [log] [blame]
Brendan Greggf06d3b42015-10-15 17:21:32 -07001Demonstrations of tcpconnect, the Linux eBPF/bcc version.
2
3
4This tool traces the kernel function performing active TCP connections
5(eg, via a connect() syscall; accept() are passive connections). Some example
6output (IP addresses changed to protect the innocent):
7
Alexei Starovoitovbdf07732016-01-14 10:09:20 -08008# ./tcpconnect
Brendan Greggf06d3b42015-10-15 17:21:32 -07009PID COMM IP SADDR DADDR DPORT
Alexei Starovoitovbdf07732016-01-14 10:09:20 -0800101479 telnet 4 127.0.0.1 127.0.0.1 23
111469 curl 4 10.201.219.236 54.245.105.25 80
121469 curl 4 10.201.219.236 54.67.101.145 80
1311072 ssh 6 ...fe8203ac ...fe82abcd 22
Brendan Greggf06d3b42015-10-15 17:21:32 -070014
15This output shows four connections, one from a "telnet" process, two from
16"curl", and one from "ssh". The output details shows the IP version, source
17address, destination address, and destination port. This traces attempted
18connections: these may have failed.
19
20IPv4 addresses are printed as dotted quads. Only the last 4 bytes of IPv6
21addresses are printed for now (check for updated versions of this tool).
22
23The overhead of this tool should be negligible, since it is only tracing the
24kernel functions performing connect. It is not tracing every packet and then
25filtering.
26
27
28The -t option prints a timestamp column:
29
30# ./tcpconnect -t
31TIME(s) PID COMM IP SADDR DADDR DPORT
3231.871 2482 local_agent 4 10.103.219.236 10.251.148.38 7001
3331.874 2482 local_agent 4 10.103.219.236 10.101.3.132 7001
3431.878 2482 local_agent 4 10.103.219.236 10.171.133.98 7101
3590.917 2482 local_agent 4 10.103.219.236 10.251.148.38 7001
3690.928 2482 local_agent 4 10.103.219.236 10.102.64.230 7001
3790.938 2482 local_agent 4 10.103.219.236 10.115.167.169 7101
38
39The output shows some periodic connections (or attempts) from a "local_agent"
40process to various other addresses. A few connections occur every minute.
41
42
43USAGE message:
44
45# ./tcpconnect -h
46usage: tcpconnect [-h] [-t] [-p PID]
47
48Trace TCP connects
49
50optional arguments:
51 -h, --help show this help message and exit
52 -t, --timestamp include timestamp on output
53 -p PID, --pid PID trace this PID only
54
55examples:
56 ./tcpconnect # trace all TCP connect()s
57 ./tcpconnect -t # include timestamps
58 ./tcpconnect -p 181 # only trace PID 181