Skip to main content
Version: main

snapshot_file

The snapshot_file gadget shows open files for running processes.

Getting started

Running the gadget:

$ kubectl gadget run ghcr.io/inspektor-gadget/gadget/snapshot_file:latest [flags]

Flags

--paths

Show full file paths (by default, only dentry names are shown).

Default value: "false"

--file-type-mask

Filter which file types to display using a bitmask. By default, only regular files and directories are shown (bitmask value 17).

Supported file types:

  • REGULAR
  • SOCKET
  • PIPE
  • BPF_MAP
  • DIRECTORY
  • CHAR_DEV
  • BLOCK_DEV
  • SYMLINK
  • OTHER

The bitmask order, from left to right, corresponds to the file types listed above.

Guide

Run a pod / container:

$ kubectl run --restart=Never --image=busybox test-snapshot-file -- sh -c 'echo hello > /tmp/demo.txt && tail -f /tmp/demo.txt'
pod/test-snapshot-file created

Now, run the gadget and see how it shows the open file:

$ kubectl gadget run snapshot_file:latest
K8S.NODE K8S.NAMESPACE K8S.PODNAME K8S.CONTAINERNAME COMM PID TID FD PATH TYPE FLAGS
minikube-docker default test-snapshot-file test-snapshot-file tail 5432 5432 3 demo.txt REGULAR O_RDONLY
^C

Finally, clean the system:

$ kubectl delete pod test-snapshot-file