Skip to main content
Version: latest

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 run ghcr.io/inspektor-gadget/gadget/trace_tcpconnect:latest [flags]

Flags

No flags.

Guide

Create an interactive test workload in another terminal:

$ kubectl run --rm -it --image busybox test-trace-tcpconnect

Then, let's run the gadget and trace some events:

$ kubectl-gadget 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:

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

Finally, to clean the system we switch back to the test workload and exit out of it:

$ exit

Architecture