github.com/inspektor-gadget/inspektor-gadget@v0.28.1/docs/builtin-gadgets/top/block-io.md (about) 1 --- 2 title: 'Using top block-io' 3 weight: 20 4 description: > 5 Periodically report block device I/O activity. 6 --- 7 8 The top block-io gadget is used to visualize the containers generating 9 the most block device input/output. 10 11 ### On Kubernetes 12 13 First, we need to create one pod for us to play with: 14 15 ```bash 16 $ kubectl run test-pod --image busybox:latest sleep inf 17 ``` 18 19 You can now use the gadget, but output will be empty: 20 21 ```bash 22 $ kubectl gadget top block-io 23 K8S.NODE K8S.NAMESPACE K8S.POD K8S.CONTAINER PID COMM R/W MAJOR MINOR BYTES TIME(µs) IOs 24 ``` 25 26 Indeed, it is waiting for I/O to occur. 27 So, open *another terminal* and keep and eye on the first one, `exec` the container and use `dd`: 28 29 ```bash 30 $ kubectl exec -ti test-pod -- dd if=/dev/zero of=/tmp/foo count=16384 31 ``` 32 33 On *the first terminal*, you should see: 34 35 ``` 36 K8S.NODE K8S.NAMESPACE K8S.POD K8S.CONTAINER PID COMM R/W MAJOR MINOR BYTES TIME(µs) IOs 37 minikube default test-pod test-pod 7767 dd W 0 0 1564672 3046 4 38 ``` 39 40 This line correspond to the block device I/O initiated by `dd`. 41 42 #### Clean everything 43 44 Congratulations! You reached the end of this guide! 45 You can now delete the pod you created: 46 47 ```bash 48 $ kubectl delete pod test-pod 49 pod "test-pod" deleted 50 ``` 51 52 ### With `ig` 53 54 Start a container that performs some IO activity: 55 56 ```bash 57 $ docker run --rm --name test-top-block-io busybox /bin/sh -c'while true; do dd if=/dev/zero of=/tmp/foo count=4096; sync; done' 58 ``` 59 60 Start the gadget on another terminal and you'll see the activity produced by the `test-top-block-io` container. 61 62 ```bash 63 $ sudo ig top block-io -c test-top-block-io 64 RUNTIME.CONTAINERNAME PID COMM R/W MAJOR MINOR BYTES TIME OPS 65 test-top-block-io 63666 sync W 253 0 24576 428 5 66 test-top-block-io 63715 dd W 253 0 2097152 4816 5 67 ... 68 ```