github.com/inspektor-gadget/inspektor-gadget@v0.28.1/docs/builtin-gadgets/trace/fsslower.md (about) 1 --- 2 title: 'Using trace fsslower' 3 weight: 20 4 description: > 5 Trace open, read, write and fsync operations slower than a threshold. 6 --- 7 8  9 10 The trace fsslower gadget streams file operations (open, read, write and 11 fsync) that are slower than a threshold. 12 13 ### On Kubernetes 14 15 In this guide you'll deploy an example workload that performs some 16 open(), read() write() and sync() calls and will trace which ones are 17 slower than 1 ms. 18 19 Let's start the gadget before running our workload: 20 21 ```bash 22 $ kubectl gadget trace fsslower -f ext4 -m 1 -p mypod 23 K8S.NODE K8S.NAMESPACE K8S.POD K8S.CONTAINER PID COMM T BYTES OFFSET LAT FILE 24 ``` 25 26 With `-f` we're indicating the type of filesystem we want to trace, 27 `ext4` in this case. The `-m` parameter indicates the threshold, in this 28 case operations taking more than 1ms will be printed. `-p` indicates 29 that we only want to trace events coming from `mypod`. 30 31 The `T` column indicates the operation type, `O` for open, `R` for read, 32 `W` for write and `F` for fsync. 33 34 In another terminal, let's create a pod that updates the apt-get cache 35 and installs git. 36 37 ```bash 38 $ kubectl run -it mypod --image ubuntu -- /bin/sh -c "apt-get update && apt-get install -y git" 39 ... 40 ``` 41 42 We can see how fsslower shows the operations that are taking longer than 1ms: 43 44 ```bash 45 $ kubectl gadget trace fsslower -f ext4 -m 1 -p mypod 46 K8S.NODE K8S.NAMESPACE K8S.POD K8S.CONTAINER PID COMM T BYTES OFFSET LAT FILE 47 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 2.66 perl-modules-5.30.list-new 48 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.49 libperl5.30:amd64.list-new 49 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.45 control 50 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.01 less.list-new 51 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.05 symbols 52 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.05 md5sums 53 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.16 control 54 ubuntu-hirsute default mypod mypod 579778 dpkg F 0 0 1.09 git.list-new 55 ubuntu-hirsute default mypod mypod 580362 dpkg F 0 0 1.16 tmp.i 56 ubuntu-hirsute default mypod mypod 580363 frontend F 0 0 1.50 templates.dat-new 57 ubuntu-hirsute default mypod mypod 582040 dpkg-trigger F 0 0 1.10 triggers 58 ubuntu-hirsute default mypod mypod 580382 frontend F 0 0 1.22 templates.dat-new 59 ubuntu-hirsute default mypod mypod 583411 dpkg F 0 0 2.25 perl-modules-5.30.list-new 60 ubuntu-hirsute default mypod mypod 583411 dpkg F 0 0 2.05 libperl5.30:amd64.list-new 61 ubuntu-hirsute default mypod mypod 583411 dpkg F 0 0 1.13 tmp.i 62 ubuntu-hirsute default mypod mypod 583411 dpkg F 0 0 1.26 updates 63 ubuntu-hirsute default mypod mypod 583411 dpkg F 0 0 1.22 md5sums 64 ``` 65 66 That's all, let's delete our example pod 67 68 ```bash 69 $ kubectl delete pod mypod 70 ``` 71 72 ### With `ig` 73 74 Let's start the gadget in a terminal: 75 76 ```bash 77 $ sudo ig trace fsslower -f ext4 -m 1 -c test-trace-fsslower 78 RUNTIME.CONTAINERNAME PID COMM T BYTES OFFSET LAT FILE 79 ``` 80 81 Launch a container that will perform input/output operations: 82 83 ```bash 84 $ docker run --name test-trace-fsslower -it --rm debian /bin/sh -c "apt-get update && apt-get install -y git" 85 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB] 86 Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB] 87 ... 88 0 added, 0 removed; done. 89 Running hooks in /etc/ca-certificates/update.d... 90 done. 91 ``` 92 93 The tool will list the I/O operations that were slower than 1ms: 94 95 ```bash 96 $ sudo ig trace fsslower -f ext4 -m 1 -c test-trace-fsslower 97 RUNTIME.CONTAINERNAME PID COMM T BYTES OFFSET LAT FILE 98 test-trace-fsslower 35065 apt-get R 32771 0 7671 status 99 test-trace-fsslower 35303 apt-get R 5619 0 7434 extended_states 100 test-trace-fsslower 35312 dpkg-preconfigu F 922337203… 0 3586 #29920952 101 test-trace-fsslower 35312 dpkg-preconfigu F 922337203… 0 4239 #29920954 102 test-trace-fsslower 35315 dpkg F 922337203… 0 3774 control 103 test-trace-fsslower 35315 dpkg F 922337203… 0 3049 md5sums 104 test-trace-fsslower 35315 dpkg F 922337203… 0 3064 tmp.ci 105 test-trace-fsslower 35315 dpkg F 922337203… 0 2886 tmp.i 106 test-trace-fsslower 35315 dpkg F 922337203… 0 4173 updates 107 ... 108 ```