trace_tcpconnect
This gadget traces outgoing TCP connect attempts initiated through the connect
system call.
For non-blocking sockets (O_NONBLOCK), the connection attempt is handled asynchronously.
In these cases, the error field may not reflect the final result of the connection attempt but may instead show 115
/EINPROGRESS
, indicating that the attempt has been initiated but is not yet complete.
Getting started
Running the gadget:
- kubectl gadget
- ig
$ kubectl gadget run ghcr.io/inspektor-gadget/gadget/trace_tcpconnect:latest [flags]
$ sudo ig run ghcr.io/inspektor-gadget/gadget/trace_tcpconnect:latest [flags]
Flags
No flags.
Guide
Create an interactive test workload in another terminal:
- kubectl gadget
- ig
$ kubectl run --rm -it --image busybox test-trace-tcpconnect
$ docker run --rm -it --name test-trace-tcpconnect busybox'
Then, let's run the gadget and trace some events:
- kubectl gadget
- ig
$ kubectl-gadget run trace_tcpconnect:latest --containername test-trace-tcpconnect
$ sudo ig run trace_tcpconnect:latest --containername test-trace-tcpconnect
To generate some event we go back to our test workload, which we created earlier, and use wget
on some hosts:
$ wget www.inspektor-gadget.io
$ wget 192.168.1.1
Now we should see some events in the terminal where the gadget is running:
- kubectl gadget
- ig
K8S.NODE K8S.NAMESPACE K8S.PODNAME K8S.CONTAINERNAME SRC DST COMM PID TID UID GID ERROR
minikube-docker default test-tra…pconnect test-trace-tcpcon 10.244.0.5:33152 188.114.96.3:80 wget 104183 104183 0 0
minikube-docker default test-tra…pconnect test-trace-tcpcon 10.244.0.5:44394 188.114.96.3:443 wget 104183 104183 0 0
minikube-docker default test-tra…pconnect test-trace-tcpcon 10.244.0.5:46028 192.168.1.1:80 wget 104997 104997 0 0 ECONNR
^C
RUNTIME.CONTAINERNAME SRC DST COMM PID TID UID GID ERROR
test-trace-tcpconnect 172.17.0.2:53208 188.114.96.3:80 wget 40138 40138 0 0
test-trace-tcpconnect 172.17.0.2:56386 188.114.96.3:443 wget 40138 40138 0 0
test-trace-tcpconnect 172.17.0.2:50946 192.168.1.1:80 wget 40697 40697 0 0 ECONNREFUS
^C
Finally, to clean the system we switch back to the test workload and exit out of it:
$ exit