@cryptotaxi247 / netdata-1 / commits / 428d925be

Update ebpf doc (#12503)

thiagoftsm committed Mar 31, 2022 at 20:56 UTC 428d925be4881addba791132058175ab89585772
1 file changed +556 -520
collectors/ebpf.plugin/README.md
+556 -520
@@ -8,51 +8,405 @@ sidebar_label: "eBPF"
8
9 # eBPF monitoring with Netdata
10
11 -eBPF consists of a wide toolchain that ultimately outputs a set of bytecode that will run inside the eBPF virtual
12 -machine (VM) which lives inside the Linux kernel. The program in particular is executed in response to a [tracepoint
13 -or kprobe](#probes-and-tracepoints) activation.
11 +The Netdata Agent provides many [eBPF](https://ebpf.io/what-is-ebpf/) programs to help you troubleshoot and debug how applications interact with the Linux kernel. The `ebpf.plugin` uses [tracepoints, trampoline, and2 kprobes](#data-collection) to collect a wide array of high value data about the host that would otherwise be impossible to capture.
12
15 -Netdata has written many eBPF programs, which, when compiled and integrated into the Netdata Agent, are able to collect
16 -a wide array of data about the host that would otherwise be impossible. The data eBPF programs can collect is truly unique,
17 -which gives the Netdata Agent access to data that is high value but normally hard to capture.
13 +> ❗ eBPF monitoring only works on Linux systems and with specific Linux kernels, including all kernels newer than `4.11.0`, and all kernels on CentOS 7.6 or later. For kernels older than `4.11.0`, improved support is in active development.
14
19 -eBPF monitoring can help you troubleshoot and debug how applications interact with the Linux kernel. See
20 -our [guide on troubleshooting apps with eBPF metrics](/docs/guides/troubleshoot/monitor-debug-applications-ebpf.md) for
21 -configuration and troubleshooting tips.
15 +This document provides comprehensive details about the `ebpf.plugin`.
16 +For hands-on configuration and troubleshooting tips see our [tutorial on troubleshooting apps with eBPF metrics](/docs/guides/troubleshoot/monitor-debug-applications-ebpf.md).
17
18 <figure>
19 <img src="https://user-images.githubusercontent.com/1153921/74746434-ad6a1e00-5222-11ea-858a-a7882617ae02.png" alt="An example of VFS charts, made possible by the eBPF collector plugin" />
25 - <figcaption>An example of VFS charts made possible by the eBPF collector plugin.</figcaption>
20 + <figcaption>An example of virtual file system (VFS) charts made possible by the eBPF collector plugin.</figcaption>
21 </figure>
22
28 -## Probes and Tracepoints
23 +<a id="data-collection"> </a>
24
30 -The following two features from the Linux kernel are used by Netdata to run eBPF programs:
25 +## How Netdata collects data using probes and tracepoints
26
32 -- Kprobes and return probes (kretprobe): Probes can insert virtually into any kernel instruction. When eBPF runs in
33 - `entry` mode, it attaches only `kprobes` for internal functions monitoring calls and some arguments every time a
34 - function is called. The user can also change configuration to use [`return`](#global) mode, and this will allow users
35 - to monitor return from these functions and detect possible failures.
36 -- Tracepoints are hooks to call specific functions. Tracepoints are more stable than `kprobes` and are preferred when
37 - both options are available.
27 +Netdata uses the following features from the Linux kernel to run eBPF programs:
28
39 -In each case, wherever a normal kprobe, kretprobe, or tracepoint would have run its hook function, an eBPF program is
40 -run instead, performing various collection logic before letting the kernel continue its normal control flow.
29 +- Tracepoints are hooks to call specific functions. Tracepoints are more stable than `kprobes` and are preferred when
30 + both options are available.
31 +- Trampolines are bridges between kernel functions, and BPF programs. Netdata uses them by default whenever available.
32 +- Kprobes and return probes (`kretprobe`): Probes can insert virtually into any kernel instruction. When eBPF runs in `entry` mode, it attaches only `kprobes` for internal functions monitoring calls and some arguments every time a function is called. The user can also change configuration to use [`return`](#global) mode, and this will allow users to monitor return from these functions and detect possible failures.
33
42 -There are more methods by which eBPF programs can be triggered but which are not currently supported, such as via uprobes
43 -which allow hooking into arbitrary user-space functions in a similar manner to kprobes.
34 +In each case, wherever a normal kprobe, kretprobe, or tracepoint would have run its hook function, an eBPF program is run instead, performing various collection logic before letting the kernel continue its normal control flow.
35
45 -## Manually enable the collector on Linux
36 +There are more methods to trigger eBPF programs, such as uprobes, but currently are not supported.
37
47 -**The eBPF collector is installed and enabled by default on most new installations of the Agent**. The eBPF collector
48 -does not currently work with [static build installations](/packaging/installer/methods/kickstart.md#static-builds) for kernels older
49 -than `4.11`, but improved support is in active development.
38 +## Configuring ebpf.plugin
39
51 -eBPF monitoring only works on Linux systems and with specific Linux kernels, including all kernels newer than `4.11.0`,
52 -and all kernels on CentOS 7.6 or later.
40 +The eBPF collector is installed and enabled by default on most new installations of the Agent.
41 +If your Agent is v1.22 or older, you may to enable the collector yourself.
42
54 -If your Agent is v1.22 or older, you may to enable the collector yourself. See the [configuration](#configuration)
55 -section for details.
43 +### Enable the eBPF collector
44 +
45 +To enable or disable the entire eBPF collector:
46 +
47 +1. Navigate to the [Netdata config directory](/docs/configure/nodes.md#the-netdata-config-directory).
48 + ```bash
49 + cd /etc/netdata
50 + ```
51 +
52 +2. Use the [`edit-config`](/docs/configure/nodes.md#use-edit-config-to-edit-configuration-files) script to edit `netdata.conf`.
53 +
54 + ```bash
55 + ./edit-config netdata.conf
56 + ```
57 +
58 +3. Enable the collector by scrolling down to the `[plugins]` section. Uncomment the line `ebpf` (not
59 + `ebpf_process`) and set it to `yes`.
60 +
61 + ```conf
62 + [plugins]
63 + ebpf = yes
64 + ```
65 +
66 +### Configure the eBPF collector
67 +
68 +You can configure the eBPF collector's behavior to fine-tune which metrics you receive and [optimize performance]\(#performance opimization).
69 +
70 +To edit the `ebpf.d.conf`:
71 +
72 +1. Navigate to the [Netdata config directory](/docs/configure/nodes.md#the-netdata-config-directory).
73 + ```bash
74 + cd /etc/netdata
75 + ```
76 +2. Use the [`edit-config`](/docs/configure/nodes.md#use-edit-config-to-edit-configuration-files) script to edit [`ebpf.d.conf`](https://github.com/netdata/netdata/blob/master/collectors/ebpf.plugin/ebpf.d.conf).
77 +
78 + ```bash
79 + ./edit-config ebpf.d.conf
80 + ```
81 +
82 + You can now edit the behavior of the eBPF collector. The following sections describe each configuration option in detail.
83 +
84 +### `[global]` configuration options
85 +
86 +The `[global]` section defines settings for the whole eBPF collector.
87 +
88 +#### eBPF load mode
89 +
90 +The collector uses two different eBPF programs. These programs rely on the same functions inside the kernel, but they
91 +monitor, process, and display different kinds of information.
92 +
93 +By default, this plugin uses the `entry` mode. Changing this mode can create significant overhead on your operating
94 +system, but also offer valuable information if you are developing or debugging software. The `ebpf load mode` option
95 +accepts the following values:
96 +
97 +- `entry`: This is the default mode. In this mode, the eBPF collector only monitors calls for the functions described in
98 + the sections above, and does not show charts related to errors.
99 +- `return`: In the `return` mode, the eBPF collector monitors the same kernel functions as `entry`, but also creates new
100 + charts for the return of these functions, such as errors. Monitoring function returns can help in debugging software,
101 + such as failing to close file descriptors or creating zombie processes.
102 +- `update every`: Number of seconds used for eBPF to send data for Netdata.
103 +- `pid table size`: Defines the maximum number of PIDs stored inside the application hash table.
104 +
105 +#### Integration with `apps.plugin`
106 +
107 +The eBPF collector also creates charts for each running application through an integration with the
108 +[`apps.plugin`](/collectors/apps.plugin/README.md). This integration helps you understand how specific applications
109 +interact with the Linux kernel.
110 +
111 +If you want to _disable_ the integration with `apps.plugin` along with the above charts, change the setting `apps` to
112 +`no`.
113 +
114 +```conf
115 +[global]
116 + apps = yes
117 +```
118 +
119 +When the integration is enabled, eBPF collector allocates memory for each process running. The total allocated memory
120 +has direct relationship with the kernel version. When the eBPF plugin is running on kernels newer than `4.15`, it uses
121 +per-cpu maps to speed up the update of hash tables. This also implies storing data for the same PID for each processor
122 +it runs.
123 +
124 +#### Integration with `cgroups.plugin`
125 +
126 +The eBPF collector also creates charts for each cgroup through an integration with the
127 +[`cgroups.plugin`](/collectors/cgroups.plugin/README.md). This integration helps you understand how a specific cgroup
128 +interacts with the Linux kernel.
129 +
130 +The integration with `cgroups.plugin` is disabled by default to avoid creating overhead on your system. If you want to
131 +_enable_ the integration with `cgroups.plugin`, change the `cgroups` setting to `yes`.
132 +
133 +```conf
134 +[global]
135 + cgroups = yes
136 +```
137 +
138 +If you do not need to monitor specific metrics for your `cgroups`, you can enable `cgroups` inside
139 +`ebpf.d.conf`, and then disable the plugin for a specific `thread` by following the steps in the
140 +[Configuration](#configuration) section.
141 +
142 +#### Integration Dashboard Elements
143 +
144 +When an integration is enabled, your dashboard will also show the following cgroups and apps charts using low-level
145 +Linux metrics:
146 +
147 +> Note: The parenthetical accompanying each bulleted item provides the chart name.
148 +
149 +- mem
150 + - Number of processes killed due out of memory. (`oomkills`)
151 +- process
152 + - Number of processes created with `do_fork`. (`process_create`)
153 + - Number of threads created with `do_fork` or `clone (2)`, depending on your system's kernel
154 + version. (`thread_create`)
155 + - Number of times that a process called `do_exit`. (`task_exit`)
156 + - Number of times that a process called `release_task`. (`task_close`)
157 + - Number of times that an error happened to create thread or process. (`task_error`)
158 +- swap
159 + - Number of calls to `swap_readpage`. (`swap_read_call`)
160 + - Number of calls to `swap_writepage`. (`swap_write_call`)
161 +- network
162 + - Number of outbound connections using TCP/IPv4. (`outbound_conn_ipv4`)
163 + - Number of outbound connections using TCP/IPv6. (`outbound_conn_ipv6`)
164 + - Number of bytes sent. (`total_bandwidth_sent`)
165 + - Number of bytes received. (`total_bandwidth_recv`)
166 + - Number of calls to `tcp_sendmsg`. (`bandwidth_tcp_send`)
167 + - Number of calls to `tcp_cleanup_rbuf`. (`bandwidth_tcp_recv`)
168 + - Number of calls to `tcp_retransmit_skb`. (`bandwidth_tcp_retransmit`)
169 + - Number of calls to `udp_sendmsg`. (`bandwidth_udp_send`)
170 + - Number of calls to `udp_recvmsg`. (`bandwidth_udp_recv`)
171 +- file access
172 + - Number of calls to open files. (`file_open`)
173 + - Number of calls to open files that returned errors. (`open_error`)
174 + - Number of files closed. (`file_closed`)
175 + - Number of calls to close files that returned errors. (`file_error_closed`)
176 +- vfs
177 + - Number of calls to `vfs_unlink`. (`file_deleted`)
178 + - Number of calls to `vfs_write`. (`vfs_write_call`)
179 + - Number of calls to write a file that returned errors. (`vfs_write_error`)
180 + - Number of calls to `vfs_read`. (`vfs_read_call`)
181 + - - Number of calls to read a file that returned errors. (`vfs_read_error`)
182 + - Number of bytes written with `vfs_write`. (`vfs_write_bytes`)
183 + - Number of bytes read with `vfs_read`. (`vfs_read_bytes`)
184 + - Number of calls to `vfs_fsync`. (`vfs_fsync`)
185 + - Number of calls to sync file that returned errors. (`vfs_fsync_error`)
186 + - Number of calls to `vfs_open`. (`vfs_open`)
187 + - Number of calls to open file that returned errors. (`vfs_open_error`)
188 + - Number of calls to `vfs_create`. (`vfs_create`)
189 + - Number of calls to open file that returned errors. (`vfs_create_error`)
190 +- page cache
191 + - Ratio of pages accessed. (`cachestat_ratio`)
192 + - Number of modified pages ("dirty"). (`cachestat_dirties`)
193 + - Number of accessed pages. (`cachestat_hits`)
194 + - Number of pages brought from disk. (`cachestat_misses`)
195 +- directory cache
196 + - Ratio of files available in directory cache. (`dc_hit_ratio`)
197 + - Number of files accessed. (`dc_reference`)
198 + - Number of files accessed that were not in cache. (`dc_not_cache`)
199 + - Number of files not found. (`dc_not_found`)
200 +- ipc shm
201 + - Number of calls to `shm_get`. (`shmget_call`)
202 + - Number of calls to `shm_at`. (`shmat_call`)
203 + - Number of calls to `shm_dt`. (`shmdt_call`)
204 + - Number of calls to `shm_ctl`. (`shmctl_call`)
205 +
206 +### `[ebpf programs]` configuration options
207 +
208 +The eBPF collector enables and runs the following eBPF programs by default:
209 +
210 +- `fd` : This eBPF program creates charts that show information about calls to open files.
211 +- `mount`: This eBPF program creates charts that show calls to syscalls mount(2) and umount(2).
212 +- `shm`: This eBPF program creates charts that show calls to syscalls shmget(2), shmat(2), shmdt(2) and shmctl(2).
213 +- `sync`: Monitor calls to syscalls sync(2), fsync(2), fdatasync(2), syncfs(2), msync(2), and sync_file_range(2).
214 +- `network viewer`: This eBPF program creates charts with information about `TCP` and `UDP` functions, including the
215 + bandwidth consumed by each.
216 +- `vfs`: This eBPF program creates charts that show information about VFS (Virtual File System) functions.
217 +- `process`: This eBPF program creates charts that show information about process life. When in `return` mode, it also
218 + creates charts showing errors when these operations are executed.
219 +- `hardirq`: This eBPF program creates charts that show information about time spent servicing individual hardware
220 + interrupt requests (hard IRQs).
221 +- `softirq`: This eBPF program creates charts that show information about time spent servicing individual software
222 + interrupt requests (soft IRQs).
223 +- `oomkill`: This eBPF program creates a chart that shows OOM kills for all applications recognized via
224 + the `apps.plugin` integration. Note that this program will show application charts regardless of whether apps
225 + integration is turned on or off.
226 +
227 +You can also enable the following eBPF programs:
228 +
229 +- `cachestat`: Netdata's eBPF data collector creates charts about the memory page cache. When the integration with
230 + [`apps.plugin`](/collectors/apps.plugin/README.md) is enabled, this collector creates charts for the whole host _and_
231 + for each application.
232 +- `dcstat` : This eBPF program creates charts that show information about file access using directory cache. It appends
233 + `kprobes` for `lookup_fast()` and `d_lookup()` to identify if files are inside directory cache, outside and files are
234 + not found.
235 +- `disk` : This eBPF program creates charts that show information about disk latency independent of filesystem.
236 +- `filesystem` : This eBPF program creates charts that show information about some filesystem latency.
237 +- `swap` : This eBPF program creates charts that show information about swap access.
238 +- `mdflush`: This eBPF program creates charts that show information about
239 + multi-device software flushes.
240 +
241 +### Configuring eBPF threads
242 +
243 +You can configure each thread of the eBPF data collector. This allows you to overwrite global options defined in `/etc/netdata/ebpf.d.conf` and configure specific options for each thread.
244 +
245 +To configure an eBPF thread:
246 +
247 +1. Navigate to the [Netdata config directory](/docs/configure/nodes.md#the-netdata-config-directory).
248 + ```bash
249 + cd /etc/netdata
250 + ```
251 +2. Use the [`edit-config`](/docs/configure/nodes.md#use-edit-config-to-edit-configuration-files) script to edit a thread configuration file. The following configuration files are available:
252 +
253 + - `network.conf`: Configuration for the [`network` thread](#network-configuration). This config file overwrites the global options and also
254 + lets you specify which network the eBPF collector monitors.
255 + - `process.conf`: Configuration for the [`process` thread](#sync-configuration).
256 + - `cachestat.conf`: Configuration for the `cachestat` thread(#filesystem-configuration).
257 + - `dcstat.conf`: Configuration for the `dcstat` thread.
258 + - `disk.conf`: Configuration for the `disk` thread.
259 + - `fd.conf`: Configuration for the `file descriptor` thread.
260 + - `filesystem.conf`: Configuration for the `filesystem` thread.
261 + - `hardirq.conf`: Configuration for the `hardirq` thread.
262 + - `softirq.conf`: Configuration for the `softirq` thread.
263 + - `sync.conf`: Configuration for the `sync` thread.
264 + - `vfs.conf`: Configuration for the `vfs` thread.
265 +
266 + ```bash
267 + ./edit-config FILE.conf
268 + ```
269 +
270 +### Network configuration
271 +
272 +The network configuration has specific options to configure which network(s) the eBPF collector monitors. These options
273 +are divided in the following sections:
274 +
275 +#### `[network connections]`
276 +
277 +You can configure the information shown on `outbound` and `inbound` charts with the settings in this section.
278 +
279 +```conf
280 +[network connections]
281 + maximum dimensions = 500
282 + resolve hostname ips = no
283 + ports = 1-1024 !145 !domain
284 + hostnames = !example.com
285 + ips = !127.0.0.1/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 fc00::/7
286 +```
287 +
288 +When you define a `ports` setting, Netdata will collect network metrics for that specific port. For example, if you
289 +write `ports = 19999`, Netdata will collect only connections for itself. The `hostnames` setting accepts
290 +[simple patterns](/libnetdata/simple_pattern/README.md). The `ports`, and `ips` settings accept negation (`!`) to deny
291 +specific values or asterisk alone to define all values.
292 +
293 +In the above example, Netdata will collect metrics for all ports between 1 and 443, with the exception of 53 (domain)
294 +and 145.
295 +
296 +The following options are available:
297 +
298 +- `ports`: Define the destination ports for Netdata to monitor.
299 +- `hostnames`: The list of hostnames that can be resolved to an IP address.
300 +- `ips`: The IP or range of IPs that you want to monitor. You can use IPv4 or IPv6 addresses, use dashes to define a
301 + range of IPs, or use CIDR values. By default, only data for private IP addresses is collected, but this can
302 + be changed with the `ips` setting.
303 +
304 +By default, Netdata displays up to 500 dimensions on network connection charts. If there are more possible dimensions,
305 +they will be bundled into the `other` dimension. You can increase the number of shown dimensions by changing
306 +the `maximum dimensions` setting.
307 +
308 +The dimensions for the traffic charts are created using the destination IPs of the sockets by default. This can be
309 +changed setting `resolve hostname ips = yes` and restarting Netdata, after this Netdata will create dimensions using
310 +the `hostnames` every time that is possible to resolve IPs to their hostnames.
311 +
312 +#### `[service name]`
313 +
314 +Netdata uses the list of services in `/etc/services` to plot network connection charts. If this file does not contain
315 +the name for a particular service you use in your infrastructure, you will need to add it to the `[service name]`
316 +section.
317 +
318 +For example, Netdata's default port (`19999`) is not listed in `/etc/services`. To associate that port with the Netdata
319 +service in network connection charts, and thus see the name of the service instead of its port, define it:
320 +
321 +```conf
322 +[service name]
323 + 19999 = Netdata
324 +```
325 +
326 +### Sync configuration
327 +
328 +The sync configuration has specific options to disable monitoring for syscalls. All syscalls are monitored by default.
329 +
330 +```conf
331 +[syscalls]
332 + sync = yes
333 + msync = yes
334 + fsync = yes
335 + fdatasync = yes
336 + syncfs = yes
337 + sync_file_range = yes
338 +```
339 +
340 +### Filesystem configuration
341 +
342 +The filesystem configuration has specific options to disable monitoring for filesystems; by default, all filesystems are
343 +monitored.
344 +
345 +```conf
346 +[filesystem]
347 + btrfsdist = yes
348 + ext4dist = yes
349 + nfsdist = yes
350 + xfsdist = yes
351 + zfsdist = yes
352 +```
353 +
354 +The ebpf program `nfsdist` monitors only `nfs` mount points.
355 +
356 +## Troubleshooting
357 +
358 +If the eBPF collector does not work, you can troubleshoot it by running the `ebpf.plugin` command and investigating its
359 +output.
360 +
361 +```bash
362 +cd /usr/libexec/netdata/plugins.d/
363 +sudo su -s /bin/bash ./ebpf.plugin
364 +```
365 +
366 +You can also use `grep` to search the Agent's `error.log` for messages related to eBPF monitoring.
367 +
368 +```bash
369 +grep -i ebpf /var/log/netdata/error.log
370 +```
371 +
372 +### Confirm kernel compatibility
373 +
374 +The eBPF collector only works on Linux systems and with specific Linux kernels. We support all kernels more recent than
375 +`4.11.0`, and all kernels on CentOS 7.6 or later.
376 +
377 +You can run our helper script to determine whether your system can support eBPF monitoring. If it returns no output, your system is ready to compile and run the eBPF collector.
378 +
379 +```bash
380 +curl -sSL https://raw.githubusercontent.com/netdata/kernel-collector/master/tools/check-kernel-config.sh | sudo bash
381 +```
382 +
383 +
384 +If you see a warning about a missing kernel
385 +configuration (`KPROBES KPROBES_ON_FTRACE HAVE_KPROBES BPF BPF_SYSCALL BPF_JIT`), you will need to recompile your kernel
386 +to support this configuration. The process of recompiling Linux kernels varies based on your distribution and version.
387 +Read the documentation for your system's distribution to learn more about the specific workflow for recompiling the
388 +kernel, ensuring that you set all the necessary
389 +
390 +- [Ubuntu](https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel)
391 +- [Debian](https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official)
392 +- [Fedora](https://fedoraproject.org/wiki/Building_a_custom_kernel)
393 +- [CentOS](https://wiki.centos.org/HowTos/Custom_Kernel)
394 +- [Arch Linux](https://wiki.archlinux.org/index.php/Kernel/Traditional_compilation)
395 +- [Slackware](https://docs.slackware.com/howtos:slackware_admin:kernelbuilding)
396 +
397 +### Mount `debugfs` and `tracefs`
398 +
399 +The eBPF collector also requires both the `tracefs` and `debugfs` filesystems. Try mounting the `tracefs` and `debugfs`
400 +filesystems using the commands below:
401 +
402 +```bash
403 +sudo mount -t debugfs nodev /sys/kernel/debug
404 +sudo mount -t tracefs nodev /sys/kernel/tracing
405 +```
406 +
407 +If they are already mounted, you will see an error. You can also configure your system's `/etc/fstab` configuration to
408 +mount these filesystems on startup. More information can be found in
409 +the [ftrace documentation](https://www.kernel.org/doc/Documentation/trace/ftrace.txt).
410
411 ## Charts
412
@@ -64,8 +418,7 @@ collected in the previous and current seconds.
418
419 ### System overview
420
67 -Not all charts within the System Overview menu are enabled by default, because they add around 100ns overhead for each
68 -function call, this number is small for a human perspective, but the functions are called many times creating an impact
421 +Not all charts within the System Overview menu are enabled by default. Charts that rely on `kprobes` are disabled by default because they add around 100ns overhead for each function call. This is a small number from a human's perspective, but the functions are called many times and create an impact
422 on host. See the [configuration](#configuration) section for details about how to enable them.
423
424 #### Processes
@@ -74,12 +427,12 @@ Internally, the Linux kernel treats both processes and threads as `tasks`. To cr
427 system calls: `fork(2)`, `vfork(2)`, and `clone(2)`. To generate this chart, the eBPF
428 collector uses the following `tracepoints` and `kprobe`:
429
77 -- `sched/sched_process_fork`: Tracepoint called after a call for `fork (2)`, `vfork (2)` and `clone (2)`.
78 -- `sched/sched_process_exec`: Tracepoint called after a exec-family syscall.
79 -- `kprobe/kernel_clone`: This is the main [`fork()`](https://elixir.bootlin.com/linux/v5.10/source/kernel/fork.c#L2415)
80 - routine since kernel `5.10.0` was released.
81 -- `kprobe/_do_fork`: Like `kernel_clone`, but this was the main function between kernels `4.2.0` and `5.9.16`
82 -- `kprobe/do_fork`: This was the main function before kernel `4.2.0`.
430 +- `sched/sched_process_fork`: Tracepoint called after a call for `fork (2)`, `vfork (2)` and `clone (2)`.
431 +- `sched/sched_process_exec`: Tracepoint called after a exec-family syscall.
432 +- `kprobe/kernel_clone`: This is the main [`fork()`](https://elixir.bootlin.com/linux/v5.10/source/kernel/fork.c#L2415)
433 + routine since kernel `5.10.0` was released.
434 +- `kprobe/_do_fork`: Like `kernel_clone`, but this was the main function between kernels `4.2.0` and `5.9.16`
435 +- `kprobe/do_fork`: This was the main function before kernel `4.2.0`.
436
437 #### Process Exit
438
@@ -88,9 +441,9 @@ system that the task is finishing its work. The second step is to release the ke
441 function `release_task`. The difference between the two dimensions can help you discover
442 [zombie processes](https://en.wikipedia.org/wiki/Zombie_process). To get the metrics, the collector uses:
443
91 -- `sched/sched_process_exit`: Tracepoint called after a task exits.
92 -- `kprobe/release_task`: This function is called when a process exits, as the kernel still needs to remove the process
93 - descriptor.
444 +- `sched/sched_process_exit`: Tracepoint called after a task exits.
445 +- `kprobe/release_task`: This function is called when a process exits, as the kernel still needs to remove the process
446 + descriptor.
447
448 #### Task error
449
@@ -100,7 +453,7 @@ process and thread creation only.
453 #### Swap
454
455 Inside the swap submenu the eBPF plugin creates the chart `swapcalls`; this chart is displaying when processes are
103 -calling functions [`swap_readpage` and `swap_writepage`](https://hzliu123.github.io/linux-kernel/Page%20Cache%20in%20Linux%202.6.pdf ),
456 +calling functions [`swap_readpage` and `swap_writepage`](https://hzliu123.github.io/linux-kernel/Page%20Cache%20in%20Linux%202.6.pdf),
457 which are functions responsible for doing IO in swap memory. To collect the exact moment that an access to swap happens,
458 the collector attaches `kprobes` for cited functions.
459
@@ -108,91 +461,108 @@ the collector attaches `kprobes` for cited functions.
461
462 The following `tracepoints` are used to measure time usage for soft IRQs:
463
111 -- [`irq/softirq_entry`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_softirq_entry): Called
112 - before softirq handler
113 -- [`irq/softirq_exit`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_softirq_exit): Called when
114 - softirq handler returns.
464 +- [`irq/softirq_entry`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_softirq_entry): Called
465 + before softirq handler
466 +- [`irq/softirq_exit`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_softirq_exit): Called when
467 + softirq handler returns.
468
469 #### Hard IRQ
470
471 The following tracepoints are used to measure the latency of servicing a
472 hardware interrupt request (hard IRQ).
473
121 -- [`irq/irq_handler_entry`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_irq_handler_entry):
122 - Called immediately before the IRQ action handler.
123 -- [`irq/irq_handler_exit`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_irq_handler_exit):
124 - Called immediately after the IRQ action handler returns.
125 -- `irq_vectors`: These are traces from `irq_handler_entry` and
126 - `irq_handler_exit` when an IRQ is handled. The following elements from vector
127 - are triggered:
128 - - `irq_vectors/local_timer_entry`
129 - - `irq_vectors/local_timer_exit`
130 - - `irq_vectors/reschedule_entry`
131 - - `irq_vectors/reschedule_exit`
132 - - `irq_vectors/call_function_entry`
133 - - `irq_vectors/call_function_exit`
134 - - `irq_vectors/call_function_single_entry`
135 - - `irq_vectors/call_function_single_xit`
136 - - `irq_vectors/irq_work_entry`
137 - - `irq_vectors/irq_work_exit`
138 - - `irq_vectors/error_apic_entry`
139 - - `irq_vectors/error_apic_exit`
140 - - `irq_vectors/thermal_apic_entry`
141 - - `irq_vectors/thermal_apic_exit`
142 - - `irq_vectors/threshold_apic_entry`
143 - - `irq_vectors/threshold_apic_exit`
144 - - `irq_vectors/deferred_error_entry`
145 - - `irq_vectors/deferred_error_exit`
146 - - `irq_vectors/spurious_apic_entry`
147 - - `irq_vectors/spurious_apic_exit`
148 - - `irq_vectors/x86_platform_ipi_entry`
149 - - `irq_vectors/x86_platform_ipi_exit`
474 +- [`irq/irq_handler_entry`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_irq_handler_entry):
475 + Called immediately before the IRQ action handler.
476 +- [`irq/irq_handler_exit`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_irq_handler_exit):
477 + Called immediately after the IRQ action handler returns.
478 +- `irq_vectors`: These are traces from `irq_handler_entry` and
479 + `irq_handler_exit` when an IRQ is handled. The following elements from vector
480 + are triggered:
481 + - `irq_vectors/local_timer_entry`
482 + - `irq_vectors/local_timer_exit`
483 + - `irq_vectors/reschedule_entry`
484 + - `irq_vectors/reschedule_exit`
485 + - `irq_vectors/call_function_entry`
486 + - `irq_vectors/call_function_exit`
487 + - `irq_vectors/call_function_single_entry`
488 + - `irq_vectors/call_function_single_xit`
489 + - `irq_vectors/irq_work_entry`
490 + - `irq_vectors/irq_work_exit`
491 + - `irq_vectors/error_apic_entry`
492 + - `irq_vectors/error_apic_exit`
493 + - `irq_vectors/thermal_apic_entry`
494 + - `irq_vectors/thermal_apic_exit`
495 + - `irq_vectors/threshold_apic_entry`
496 + - `irq_vectors/threshold_apic_exit`
497 + - `irq_vectors/deferred_error_entry`
498 + - `irq_vectors/deferred_error_exit`
499 + - `irq_vectors/spurious_apic_entry`
500 + - `irq_vectors/spurious_apic_exit`
501 + - `irq_vectors/x86_platform_ipi_entry`
502 + - `irq_vectors/x86_platform_ipi_exit`
503
504 #### IPC shared memory
505
153 -To monitor shared memory system call counts, the following `kprobes` are used:
506 +To monitor shared memory system call counts, Netdata attaches tracing in the following functions:
507
155 -- `shmget`: Runs when [`shmget`](https://man7.org/linux/man-pages/man2/shmget.2.html) is called.
156 -- `shmat`: Runs when [`shmat`](https://man7.org/linux/man-pages/man2/shmat.2.html) is called.
157 -- `shmdt`: Runs when [`shmdt`](https://man7.org/linux/man-pages/man2/shmat.2.html) is called.
158 -- `shmctl`: Runs when [`shmctl`](https://man7.org/linux/man-pages/man2/shmctl.2.html) is called.
508 +- `shmget`: Runs when [`shmget`](https://man7.org/linux/man-pages/man2/shmget.2.html) is called.
509 +- `shmat`: Runs when [`shmat`](https://man7.org/linux/man-pages/man2/shmat.2.html) is called.
510 +- `shmdt`: Runs when [`shmdt`](https://man7.org/linux/man-pages/man2/shmat.2.html) is called.
511 +- `shmctl`: Runs when [`shmctl`](https://man7.org/linux/man-pages/man2/shmctl.2.html) is called.
512
513 ### Memory
514
515 In the memory submenu the eBPF plugin creates two submenus **page cache** and **synchronization** with the following
516 organization:
517
165 -* Page Cache
166 - * Page cache ratio
167 - * Dirty pages
168 - * Page cache hits
169 - * Page cache misses
170 -* Synchronization
171 - * File sync
172 - * Memory map sync
173 - * File system sync
174 - * File range sync
518 +- Page Cache
519 + - Page cache ratio
520 + - Dirty pages
521 + - Page cache hits
522 + - Page cache misses
523 +- Synchronization
524 + - File sync
525 + - Memory map sync
526 + - File system sync
527 + - File range sync
528
176 -#### Page cache ratio
529 +#### Page cache hits
530
178 -The chart `cachestat_ratio` shows how processes are accessing page cache. In a normal scenario, we expect values around
179 -100%, which means that the majority of the work on the machine is processed in memory. To calculate the ratio, Netdata
180 -attaches `kprobes` for kernel functions:
531 +When the processor needs to read or write a location in main memory, it checks for a corresponding entry in the page cache.
532 + If the entry is there, a page cache hit has occurred and the read is from the cache.
533
182 -- `add_to_page_cache_lru`: Page addition.
183 -- `mark_page_accessed`: Access to cache.
184 -- `account_page_dirtied`: Dirty (modified) pages.
185 -- `mark_buffer_dirty`: Writes to page cache.
534 +A page cache hit is when the page cache is successfully accessed with a read operation. We do not count pages that were
535 +added relatively recently.
536
537 #### Dirty pages
538
539 +A "dirty page" is a page in the page cache that was modified after being created. Since non-dirty pages in the page cache
540 + have identical copies in secondary storage (e.g. hard disk drive or solid-state drive), discarding and reusing their space
541 + is much quicker than paging out application memory, and is often preferred over flushing the dirty pages into secondary storage
542 + and reusing their space.
543 +
544 On `cachestat_dirties` Netdata demonstrates the number of pages that were modified. This chart shows the number of calls
545 to the function `mark_buffer_dirty`.
546
192 -#### Page cache hits
547 +#### Page cache ratio
548
194 -A page cache hit is when the page cache is successfully accessed with a read operation. We do not count pages that were
195 -added relatively recently.
549 +When the processor needs to read or write in a specific memory address, it checks for a corresponding entry in the page cache.
550 +If the processor hits a page cache (`page cache hit`), it reads the entry from the cache. If there is no entry (`page cache miss`),
551 + the kernel allocates a new entry and copies data from the disk. Netdata calculates the percentage of accessed files that are cached on
552 + memory. The ratio is calculated counting the accessed cached pages
553 + (without counting [dirty pages](#dirty-pages) and pages added because of read misses) divided by total access without dirty pages.
554 +
555 +> \_\_**\_\_\_\_**<ins>Number of accessed cached pages</ins>\***\*\_\_\*\***<br/>
556 +> Number of total accessed pages - dirty pages - missed pages
557 +
558 +The chart `cachestat_ratio` shows how processes are accessing page cache. In a normal scenario, we expect values around
559 +100%, which means that the majority of the work on the machine is processed in memory. To calculate the ratio, Netdata
560 +attaches `kprobes` for kernel functions:
561 +
562 +- `add_to_page_cache_lru`: Page addition.
563 +- `mark_page_accessed`: Access to cache.
564 +- `account_page_dirtied`: Dirty (modified) pages.
565 +- `mark_buffer_dirty`: Writes to page cache.
566
567 #### Page cache misses
568
@@ -213,7 +583,7 @@ changes to a file that was mapped into memory using [`mmap(2)`](https://man7.org
583
584 #### File system sync
585
216 -This chart monitors calls demonstrating commits from filesystem caches to disk. Netdata attaches `kprobes` for
586 +This chart monitors calls demonstrating commits from filesystem caches to disk. Netdata attaches `tracing` for
587 [`sync(2)`](https://man7.org/linux/man-pages/man2/sync.2.html), and [`syncfs(2)`](https://man7.org/linux/man-pages/man2/sync.2.html).
588
589 #### File range sync
@@ -240,19 +610,20 @@ By default, MD flush is disabled. To enable it, configure your
610
611 To collect data related to Linux multi-device (MD) flushing, the following kprobe is used:
612
243 -- `kprobe/md_flush_request`: called whenever a request for flushing multi-device data is made.
613 +- `kprobe/md_flush_request`: called whenever a request for flushing multi-device data is made.
614
615 ### Disk
616
617 The eBPF plugin also shows a chart in the Disk section when the `disk` thread is enabled.
618
619 #### Disk Latency
620 +
621 This will create the chart `disk_latency_io` for each disk on the host. The following tracepoints are used:
622
252 -- [`block/block_rq_issue`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_block_rq_issue):
253 - IO request operation to a device drive.
254 -- [`block/block_rq_complete`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_block_rq_complete):
255 - IO operation completed by device.
623 +- [`block/block_rq_issue`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_block_rq_issue):
624 + IO request operation to a device drive.
625 +- [`block/block_rq_complete`](https://www.kernel.org/doc/html/latest/core-api/tracepoint.html#c.trace_block_rq_complete):
626 + IO operation completed by device.
627
628 Disk Latency is the single most important metric to focus on when it comes to storage performance, under most circumstances.
629 For hard drives, an average latency somewhere between 10 to 20 ms can be considered acceptable. For SSD (Solid State Drives),
@@ -265,6 +636,7 @@ This group has charts demonstrating how applications interact with the Linux ker
636 It also brings latency charts for several different filesystems.
637
638 #### Latency Algorithm
639 +
640 We calculate the difference between the calling and return times, spanning disk I/O, file system operations (lock, I/O),
641 run queue latency and all events related to the monitored action.
642
@@ -275,10 +647,10 @@ To measure the latency of executing some actions in an
647 collector needs to attach `kprobes` and `kretprobes` for each of the following
648 functions:
649
278 -- `ext4_file_read_iter`: Function used to measure read latency.
279 -- `ext4_file_write_iter`: Function used to measure write latency.
280 -- `ext4_file_open`: Function used to measure open latency.
281 -- `ext4_sync_file`: Function used to measure sync latency.
650 +- `ext4_file_read_iter`: Function used to measure read latency.
651 +- `ext4_file_write_iter`: Function used to measure write latency.
652 +- `ext4_file_open`: Function used to measure open latency.
653 +- `ext4_sync_file`: Function used to measure sync latency.
654
655 #### ZFS
656
@@ -286,10 +658,10 @@ To measure the latency of executing some actions in a zfs filesystem, the
658 collector needs to attach `kprobes` and `kretprobes` for each of the following
659 functions:
660
289 -- `zpl_iter_read`: Function used to measure read latency.
290 -- `zpl_iter_write`: Function used to measure write latency.
291 -- `zpl_open`: Function used to measure open latency.
292 -- `zpl_fsync`: Function used to measure sync latency.
661 +- `zpl_iter_read`: Function used to measure read latency.
662 +- `zpl_iter_write`: Function used to measure write latency.
663 +- `zpl_open`: Function used to measure open latency.
664 +- `zpl_fsync`: Function used to measure sync latency.
665
666 #### XFS
667
@@ -298,10 +670,10 @@ To measure the latency of executing some actions in an
670 collector needs to attach `kprobes` and `kretprobes` for each of the following
671 functions:
672
301 -- `xfs_file_read_iter`: Function used to measure read latency.
302 -- `xfs_file_write_iter`: Function used to measure write latency.
303 -- `xfs_file_open`: Function used to measure open latency.
304 -- `xfs_file_fsync`: Function used to measure sync latency.
673 +- `xfs_file_read_iter`: Function used to measure read latency.
674 +- `xfs_file_write_iter`: Function used to measure write latency.
675 +- `xfs_file_open`: Function used to measure open latency.
676 +- `xfs_file_fsync`: Function used to measure sync latency.
677
678 #### NFS
679
@@ -310,11 +682,11 @@ To measure the latency of executing some actions in an
682 collector needs to attach `kprobes` and `kretprobes` for each of the following
683 functions:
684
313 -- `nfs_file_read`: Function used to measure read latency.
314 -- `nfs_file_write`: Function used to measure write latency.
315 -- `nfs_file_open`: Functions used to measure open latency.
316 -- `nfs4_file_open`: Functions used to measure open latency for NFS v4.
317 -- `nfs_getattr`: Function used to measure sync latency.
685 +- `nfs_file_read`: Function used to measure read latency.
686 +- `nfs_file_write`: Function used to measure write latency.
687 +- `nfs_file_open`: Functions used to measure open latency.
688 +- `nfs4_file_open`: Functions used to measure open latency for NFS v4.
689 +- `nfs_getattr`: Function used to measure sync latency.
690
691 #### btrfs
692
@@ -322,26 +694,26 @@ To measure the latency of executing some actions in a [btrfs](https://elixir.boo
694 filesystem, the collector needs to attach `kprobes` and `kretprobes` for each of the following functions:
695
696 > Note: We are listing two functions used to measure `read` latency, but we use either `btrfs_file_read_iter` or
325 -`generic_file_read_iter`, depending on kernel version.
697 +> `generic_file_read_iter`, depending on kernel version.
698
327 -- `btrfs_file_read_iter`: Function used to measure read latency since kernel `5.10.0`.
328 -- `generic_file_read_iter`: Like `btrfs_file_read_iter`, but this function was used before kernel `5.10.0`.
329 -- `btrfs_file_write_iter`: Function used to write data.
330 -- `btrfs_file_open`: Function used to open files.
331 -- `btrfs_sync_file`: Function used to synchronize data to filesystem.
699 +- `btrfs_file_read_iter`: Function used to measure read latency since kernel `5.10.0`.
700 +- `generic_file_read_iter`: Like `btrfs_file_read_iter`, but this function was used before kernel `5.10.0`.
701 +- `btrfs_file_write_iter`: Function used to write data.
702 +- `btrfs_file_open`: Function used to open files.
703 +- `btrfs_sync_file`: Function used to synchronize data to filesystem.
704
705 #### File descriptor
706
707 To give metrics related to `open` and `close` events, instead of attaching kprobes for each syscall used to do these
708 events, the collector attaches `kprobes` for the common function used for syscalls:
709
338 -- [`do_sys_open`](https://0xax.gitbooks.io/linux-insides/content/SysCall/linux-syscall-5.html ): Internal function used to
339 - open files.
340 -- [`do_sys_openat2`](https://elixir.bootlin.com/linux/v5.6/source/fs/open.c#L1162):
341 - Function called from `do_sys_open` since version `5.6.0`.
342 -- [`close_fd`](https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2271761.html): Function used to close file
343 - descriptor since kernel `5.11.0`.
344 -- `__close_fd`: Function used to close files before version `5.11.0`.
710 +- [`do_sys_open`](https://0xax.gitbooks.io/linux-insides/content/SysCall/linux-syscall-5.html): Internal function used to
711 + open files.
712 +- [`do_sys_openat2`](https://elixir.bootlin.com/linux/v5.6/source/fs/open.c#L1162):
713 + Function called from `do_sys_open` since version `5.6.0`.
714 +- [`close_fd`](https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2271761.html): Function used to close file
715 + descriptor since kernel `5.11.0`.
716 +- `__close_fd`: Function used to close files before version `5.11.0`.
717
718 #### File error
719
@@ -361,22 +733,22 @@ To measure the latency and total quantity of executing some VFS-level
733 functions, ebpf.plugin needs to attach kprobes and kretprobes for each of the
734 following functions:
735
364 -- `vfs_write`: Function used monitoring the number of successful & failed
365 - filesystem write calls, as well as the total number of written bytes.
366 -- `vfs_writev`: Same function as `vfs_write` but for vector writes (i.e. a
367 - single write operation using a group of buffers rather than 1).
368 -- `vfs_read`: Function used for monitoring the number of successful & failed
369 - filesystem read calls, as well as the total number of read bytes.
370 -- `vfs_readv` Same function as `vfs_read` but for vector reads (i.e. a single
371 - read operation using a group of buffers rather than 1).
372 -- `vfs_unlink`: Function used for monitoring the number of successful & failed
373 - filesystem unlink calls.
374 -- `vfs_fsync`: Function used for monitoring the number of successful & failed
375 - filesystem fsync calls.
376 -- `vfs_open`: Function used for monitoring the number of successful & failed
377 - filesystem open calls.
378 -- `vfs_create`: Function used for monitoring the number of successful & failed
379 - filesystem create calls.
736 +- `vfs_write`: Function used monitoring the number of successful & failed
737 + filesystem write calls, as well as the total number of written bytes.
738 +- `vfs_writev`: Same function as `vfs_write` but for vector writes (i.e. a
739 + single write operation using a group of buffers rather than 1).
740 +- `vfs_read`: Function used for monitoring the number of successful & failed
741 + filesystem read calls, as well as the total number of read bytes.
742 +- `vfs_readv` Same function as `vfs_read` but for vector reads (i.e. a single
743 + read operation using a group of buffers rather than 1).
744 +- `vfs_unlink`: Function used for monitoring the number of successful & failed
745 + filesystem unlink calls.
746 +- `vfs_fsync`: Function used for monitoring the number of successful & failed
747 + filesystem fsync calls.
748 +- `vfs_open`: Function used for monitoring the number of successful & failed
749 + filesystem open calls.
750 +- `vfs_create`: Function used for monitoring the number of successful & failed
751 + filesystem create calls.
752
753 ##### VFS Deleted objects
754
@@ -416,35 +788,49 @@ Metrics for directory cache are collected using kprobe for `lookup_fast`, becaus
788 times this function is accessed. On the other hand, for `d_lookup` we are not only interested in the number of times it
789 is accessed, but also in possible errors, so we need to attach a `kretprobe`. For this reason, the following is used:
790
419 -- [`lookup_fast`](https://lwn.net/Articles/649115/): Called to look at data inside the directory cache.
420 -- [`d_lookup`](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/dcache.c?id=052b398a43a7de8c68c13e7fa05d6b3d16ce6801#n2223):
421 - Called when the desired file is not inside the directory cache.
791 +- [`lookup_fast`](https://lwn.net/Articles/649115/): Called to look at data inside the directory cache.
792 +- [`d_lookup`](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/dcache.c?id=052b398a43a7de8c68c13e7fa05d6b3d16ce6801#n2223):
793 + Called when the desired file is not inside the directory cache.
794
795 ##### Directory Cache Interpretation
796 +
797 When directory cache is showing 100% that means that every accessed file was present in the directory cache.
798 If files are not present in the directory cache, they are either not present in the file system or the files were not
799 accessed before.
800
801 ### Mount Points
802
430 -The following `kprobes` are used to collect `mount` & `unmount` call counts:
803 +The following `tracing` are used to collect `mount` & `unmount` call counts:
804
432 -- [`mount`](https://man7.org/linux/man-pages/man2/mount.2.html): mount filesystem on host.
433 -- [`umount`](https://man7.org/linux/man-pages/man2/umount.2.html): umount filesystem on host.
805 +- [`mount`](https://man7.org/linux/man-pages/man2/mount.2.html): mount filesystem on host.
806 +- [`umount`](https://man7.org/linux/man-pages/man2/umount.2.html): umount filesystem on host.
807
808 ### Networking Stack
809
437 -Netdata monitors socket bandwidth attaching `kprobes` for internal functions.
810 +Netdata monitors socket bandwidth attaching `tracing` for internal functions.
811 +
812 +#### TCP outbound connections
813 +
814 +This chart demonstrates calls to `tcp_v4_connection` and `tcp_v6_connection` that start connections for IPV4 and IPV6, respectively.
815
439 -#### TCP functions
816 +#### TCP inbound connections
817 +
818 +This chart demonstrates TCP and UDP connections that the host receives.
819 +To collect this information, netdata attaches a tracing to `inet_csk_accept`.
820 +
821 +#### TCP bandwidth functions
822
823 This chart demonstrates calls to functions `tcp_sendmsg`, `tcp_cleanup_rbuf`, and `tcp_close`; these functions are used
824 to send & receive data and to close connections when `TCP` protocol is used.
825
826 #### TCP bandwidth
827
446 -Like the previous chart, this one also monitors `tcp_sendmsg` and `tcp_cleanup_rbuf`, but instead of showing the number
447 -of calls, it demonstrates the number of bytes sent and received.
828 +This chart demonstrates calls to functions:
829 +
830 +- `tcp_sendmsg`: Function responsible to send data for a specified destination.
831 +- `tcp_cleanup_rbuf`: We use this function instead of `tcp_recvmsg`, because the last one misses `tcp_read_sock` traffic
832 + and we would also need to add more `tracing` to get the socket and package size.
833 +- `tcp_close`: Function responsible to close connection.
834
835 #### TCP retransmit
836
@@ -467,359 +853,11 @@ calls, it monitors the number of bytes sent and received.
853
854 These are tracepoints related to [OOM](https://en.wikipedia.org/wiki/Out_of_memory) killing processes.
855
470 -- `oom/mark_victim`: Monitors when an oomkill event happens.
471 -
472 -## Configuration
473 -
474 -Enable or disable the entire eBPF collector by editing `netdata.conf`.
475 -
476 -```bash
477 -cd /etc/netdata/ # Replace with your Netdata configuration directory, if not /etc/netdata/
478 -./edit-config netdata.conf
479 -```
480 -
481 -To enable the collector, scroll down to the `[plugins]` section ensure the relevant line references `ebpf` (not
482 -`ebpf_process`), is uncommented, and is set to `yes`.
483 -
484 -```conf
485 -[plugins]
486 - ebpf = yes
487 -```
488 -
489 -You can also configure the eBPF collector's behavior by editing `ebpf.d.conf`.
490 -
491 -```bash
492 -cd /etc/netdata/ # Replace with your Netdata configuration directory, if not /etc/netdata/
493 -./edit-config ebpf.d.conf
494 -```
495 -
496 -### `[global]`
497 -
498 -The `[global]` section defines settings for the whole eBPF collector.
499 -
500 -#### eBPF load mode
501 -
502 -The collector has two different eBPF programs. These programs monitor the same functions inside the kernel, but they
503 -monitor, process, and display different kinds of information.
504 -
505 -By default, this plugin uses the `entry` mode. Changing this mode can create significant overhead on your operating
506 -system, but also offer valuable information if you are developing or debugging software. The `ebpf load mode` option
507 -accepts the following values: ​
508 -
509 -- `entry`: This is the default mode. In this mode, the eBPF collector only monitors calls for the functions described in
510 - the sections above, and does not show charts related to errors.
511 -- `return`: In the `return` mode, the eBPF collector monitors the same kernel functions as `entry`, but also creates new
512 - charts for the return of these functions, such as errors. Monitoring function returns can help in debugging software,
513 - such as failing to close file descriptors or creating zombie processes.
514 -- `update every`: Number of seconds used for eBPF to send data for Netdata.
515 -- `pid table size`: Defines the maximum number of PIDs stored inside the application hash table.
516 -
517 -#### Integration with `apps.plugin`
518 -
519 -The eBPF collector also creates charts for each running application through an integration with the
520 -[`apps.plugin`](/collectors/apps.plugin/README.md). This integration helps you understand how specific applications
521 -interact with the Linux kernel.
522 -
523 -If you want to _disable_ the integration with `apps.plugin` along with the above charts, change the setting `apps` to
524 -`no`.
525 -
526 -```conf
527 -[global]
528 - apps = yes
529 -```
530 -
531 -When the integration is enabled, eBPF collector allocates memory for each process running. The total allocated memory
532 -has direct relationship with the kernel version. When the eBPF plugin is running on kernels newer than `4.15`, it uses
533 -per-cpu maps to speed up the update of hash tables. This also implies storing data for the same PID for each processor
534 -it runs.
535 -
536 -#### Integration with `cgroups.plugin`
537 -
538 -The eBPF collector also creates charts for each cgroup through an integration with the
539 -[`cgroups.plugin`](/collectors/cgroups.plugin/README.md). This integration helps you understand how a specific cgroup
540 -interacts with the Linux kernel.
541 -
542 -The integration with `cgroups.plugin` is disabled by default to avoid creating overhead on your system. If you want to
543 -_enable_ the integration with `cgroups.plugin`, change the `cgroups` setting to `yes`.
544 -
545 -```conf
546 -[global]
547 - cgroups = yes
548 -```
549 -
550 -If you do not need to monitor specific metrics for your `cgroups`, you can enable `cgroups` inside
551 -`ebpf.d.conf`, and then disable the plugin for a specific `thread` by following the steps in the
552 -[Configuration](#configuration) section.
553 -
554 -#### Integration Dashboard Elements
555 -
556 -When an integration is enabled, your dashboard will also show the following cgroups and apps charts using low-level
557 -Linux metrics:
558 -
559 -> Note: The parenthetical accompanying each bulleted item provides the chart name.
560 -
561 -- mem
562 - - Number of processes killed due out of memory. (`oomkills`)
563 -- process
564 - - Number of processes created with `do_fork`. (`process_create`)
565 - - Number of threads created with `do_fork` or `clone (2)`, depending on your system's kernel
566 - version. (`thread_create`)
567 - - Number of times that a process called `do_exit`. (`task_exit`)
568 - - Number of times that a process called `release_task`. (`task_close`)
569 - - Number of times that an error happened to create thread or process. (`task_error`)
570 -- swap
571 - - Number of calls to `swap_readpage`. (`swap_read_call`)
572 - - Number of calls to `swap_writepage`. (`swap_write_call`)
573 -- network
574 - - Number of bytes sent. (`total_bandwidth_sent`)
575 - - Number of bytes received. (`total_bandwidth_recv`)
576 - - Number of calls to `tcp_sendmsg`. (`bandwidth_tcp_send`)
577 - - Number of calls to `tcp_cleanup_rbuf`. (`bandwidth_tcp_recv`)
578 - - Number of calls to `tcp_retransmit_skb`. (`bandwidth_tcp_retransmit`)
579 - - Number of calls to `udp_sendmsg`. (`bandwidth_udp_send`)
580 - - Number of calls to `udp_recvmsg`. (`bandwidth_udp_recv`)
581 -- file access
582 - - Number of calls to open files. (`file_open`)
583 - - Number of calls to open files that returned errors. (`open_error`)
584 - - Number of files closed. (`file_closed`)
585 - - Number of calls to close files that returned errors. (`file_error_closed`)
586 -- vfs
587 - - Number of calls to `vfs_unlink`. (`file_deleted`)
588 - - Number of calls to `vfs_write`. (`vfs_write_call`)
589 - - Number of calls to write a file that returned errors. (`vfs_write_error`)
590 - - Number of calls to `vfs_read`. (`vfs_read_call`)
591 - - Number of bytes written with `vfs_write`. (`vfs_write_bytes`)
592 - - Number of bytes read with `vfs_read`. (`vfs_read_bytes`)
593 - - Number of calls to read a file that returned errors. (`vfs_read_error`)
594 - - Number of calls to `vfs_fsync`. (`vfs_fsync`)
595 - - Number of calls to sync file that returned errors. (`vfs_fsync_error`)
596 - - Number of calls to `vfs_open`. (`vfs_open`)
597 - - Number of calls to open file that returned errors. (`vfs_open_error`)
598 - - Number of calls to `vfs_create`. (`vfs_create`)
599 - - Number of calls to open file that returned errors. (`vfs_create_error`)
600 -- page cache
601 - - Ratio of pages accessed. (`cachestat_ratio`)
602 - - Number of modified pages ("dirty"). (`cachestat_dirties`)
603 - - Number of accessed pages. (`cachestat_hits`)
604 - - Number of pages brought from disk. (`cachestat_misses`)
605 -- directory cache
606 - - Ratio of files available in directory cache. (`dc_hit_ratio`)
607 - - Number of files accessed. (`dc_reference`)
608 - - Number of files accessed that were not in cache. (`dc_not_cache`)
609 - - Number of files not found. (`dc_not_found`)
610 -- ipc shm
611 - - Number of calls to `shm_get`. (`shmget_call`)
612 - - Number of calls to `shm_at`. (`shmat_call`)
613 - - Number of calls to `shm_dt`. (`shmdt_call`)
614 - - Number of calls to `shm_ctl`. (`shmctl_call`)
615 -
616 -### `[ebpf programs]`
617 -
618 -The eBPF collector enables and runs the following eBPF programs by default:
619 -
620 -- `fd` : This eBPF program creates charts that show information about calls to open files.
621 -- `mount`: This eBPF program creates charts that show calls to syscalls mount(2) and umount(2).
622 -- `shm`: This eBPF program creates charts that show calls to syscalls shmget(2), shmat(2), shmdt(2) and shmctl(2).
623 -- `sync`: Monitor calls to syscalls sync(2), fsync(2), fdatasync(2), syncfs(2), msync(2), and sync_file_range(2).
624 -- `network viewer`: This eBPF program creates charts with information about `TCP` and `UDP` functions, including the
625 - bandwidth consumed by each.
626 -- `vfs`: This eBPF program creates charts that show information about VFS (Virtual File System) functions.
627 -- `process`: This eBPF program creates charts that show information about process life. When in `return` mode, it also
628 - creates charts showing errors when these operations are executed.
629 -- `hardirq`: This eBPF program creates charts that show information about time spent servicing individual hardware
630 - interrupt requests (hard IRQs).
631 -- `softirq`: This eBPF program creates charts that show information about time spent servicing individual software
632 - interrupt requests (soft IRQs).
633 -- `oomkill`: This eBPF program creates a chart that shows OOM kills for all applications recognized via
634 - the `apps.plugin` integration. Note that this program will show application charts regardless of whether apps
635 - integration is turned on or off.
636 -
637 -You can also enable the following eBPF programs:
638 -
639 -- `cachestat`: Netdata's eBPF data collector creates charts about the memory page cache. When the integration with
640 - [`apps.plugin`](/collectors/apps.plugin/README.md) is enabled, this collector creates charts for the whole host _and_
641 - for each application.
642 -- `dcstat` : This eBPF program creates charts that show information about file access using directory cache. It appends
643 - `kprobes` for `lookup_fast()` and `d_lookup()` to identify if files are inside directory cache, outside and files are
644 - not found.
645 -- `disk` : This eBPF program creates charts that show information about disk latency independent of filesystem.
646 -- `filesystem` : This eBPF program creates charts that show information about some filesystem latency.
647 -- `swap` : This eBPF program creates charts that show information about swap access.
648 -- `mdflush`: This eBPF program creates charts that show information about
649 - multi-device software flushes.
650 -
651 -## Thread configuration
652 -
653 -You can configure each thread of the eBPF data collector by editing either the `cachestat.conf`, `process.conf`,
654 -or `network.conf` files. Use [`edit-config`](/docs/configure/nodes.md) from your Netdata config directory:
655 -
656 -```bash
657 -cd /etc/netdata/ # Replace with your Netdata configuration directory, if not /etc/netdata/
658 -./edit-config ebpf.d/process.conf
659 -```
660 -
661 -### Configuration files
662 -
663 -The following configuration files are available:
664 -
665 -- `cachestat.conf`: Configuration for the `cachestat` thread.
666 -- `dcstat.conf`: Configuration for the `dcstat` thread.
667 -- `disk.conf`: Configuration for the `disk` thread.
668 -- `fd.conf`: Configuration for the `file descriptor` thread.
669 -- `filesystem.conf`: Configuration for the `filesystem` thread.
670 -- `hardirq.conf`: Configuration for the `hardirq` thread.
671 -- `process.conf`: Configuration for the `process` thread.
672 -- `network.conf`: Configuration for the `network viewer` thread. This config file overwrites the global options and also
673 - lets you specify which network the eBPF collector monitors.
674 -- `softirq.conf`: Configuration for the `softirq` thread.
675 -- `sync.conf`: Configuration for the `sync` thread.
676 -- `vfs.conf`: Configuration for the `vfs` thread.
677 -
678 -### Network configuration
679 -
680 -The network configuration has specific options to configure which network(s) the eBPF collector monitors. These options
681 -are divided in the following sections:
682 -
683 -#### `[network connections]`
684 -
685 -You can configure the information shown on `outbound` and `inbound` charts with the settings in this section.
686 -
687 -```conf
688 -[network connections]
689 - maximum dimensions = 500
690 - resolve hostname ips = no
691 - ports = 1-1024 !145 !domain
692 - hostnames = !example.com
693 - ips = !127.0.0.1/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 fc00::/7
694 -```
695 -
696 -When you define a `ports` setting, Netdata will collect network metrics for that specific port. For example, if you
697 -write `ports = 19999`, Netdata will collect only connections for itself. The `hostnames` setting accepts
698 -[simple patterns](/libnetdata/simple_pattern/README.md). The `ports`, and `ips` settings accept negation (`!`) to deny
699 -specific values or asterisk alone to define all values.
700 -
701 -In the above example, Netdata will collect metrics for all ports between 1 and 443, with the exception of 53 (domain)
702 -and 145.
703 -
704 -The following options are available:
705 -
706 -- `ports`: Define the destination ports for Netdata to monitor.
707 -- `hostnames`: The list of hostnames that can be resolved to an IP address.
708 -- `ips`: The IP or range of IPs that you want to monitor. You can use IPv4 or IPv6 addresses, use dashes to define a
709 - range of IPs, or use CIDR values. The default behavior is to only collect data for private IP addresses, but this can
710 - be changed with the `ips` setting.
711 -
712 -By default, Netdata displays up to 500 dimensions on network connection charts. If there are more possible dimensions,
713 -they will be bundled into the `other` dimension. You can increase the number of shown dimensions by changing
714 -the `maximum dimensions` setting.
856 +- `oom/mark_victim`: Monitors when an oomkill event happens.
857
716 -The dimensions for the traffic charts are created using the destination IPs of the sockets by default. This can be
717 -changed setting `resolve hostname ips = yes` and restarting Netdata, after this Netdata will create dimensions using
718 -the `hostnames` every time that is possible to resolve IPs to their hostnames.
719 -
720 -#### `[service name]`
721 -
722 -Netdata uses the list of services in `/etc/services` to plot network connection charts. If this file does not contain
723 -the name for a particular service you use in your infrastructure, you will need to add it to the `[service name]`
724 -section.
858 +## Known issues
859
726 -For example, Netdata's default port (`19999`) is not listed in `/etc/services`. To associate that port with the Netdata
727 -service in network connection charts, and thus see the name of the service instead of its port, define it:
728 -
729 -```conf
730 -[service name]
731 - 19999 = Netdata
732 -```
733 -
734 -### Sync configuration
735 -
736 -The sync configuration has specific options to disable monitoring for syscalls, as default option all syscalls are
737 -monitored.
738 -
739 -```conf
740 -[syscalls]
741 - sync = yes
742 - msync = yes
743 - fsync = yes
744 - fdatasync = yes
745 - syncfs = yes
746 - sync_file_range = yes
747 -```
748 -
749 -### Filesystem configuration
750 -
751 -The filesystem configuration has specific options to disable monitoring for filesystems, by default all filesystems are
752 -monitored.
753 -
754 -```conf
755 -[filesystem]
756 - btrfsdist = yes
757 - ext4dist = yes
758 - nfsdist = yes
759 - xfsdist = yes
760 - zfsdist = yes
761 -```
762 -
763 -The ebpf program `nfsdist` monitors only `nfs` mount points.
764 -
765 -## Troubleshooting
766 -
767 -If the eBPF collector does not work, you can troubleshoot it by running the `ebpf.plugin` command and investigating its
768 -output.
769 -
770 -```bash
771 -cd /usr/libexec/netdata/plugins.d/
772 -sudo su -s /bin/bash netdata
773 -./ebpf.plugin
774 -```
775 -
776 -You can also use `grep` to search the Agent's `error.log` for messages related to eBPF monitoring.
777 -
778 -```bash
779 -grep -i ebpf /var/log/netdata/error.log
780 -```
781 -
782 -### Confirm kernel compatibility
783 -
784 -The eBPF collector only works on Linux systems and with specific Linux kernels. We support all kernels more recent than
785 -`4.11.0`, and all kernels on CentOS 7.6 or later.
786 -
787 -You can run our helper script to determine whether your system can support eBPF monitoring.
788 -
789 -```bash
790 -curl -sSL https://raw.githubusercontent.com/netdata/kernel-collector/master/tools/check-kernel-config.sh | sudo bash
791 -```
792 -
793 -If this script returns no output, your system is ready to compile and run the eBPF collector.
794 -
795 -If you see a warning about a missing kernel
796 -configuration (`KPROBES KPROBES_ON_FTRACE HAVE_KPROBES BPF BPF_SYSCALL BPF_JIT`), you will need to recompile your kernel
797 -to support this configuration. The process of recompiling Linux kernels varies based on your distribution and version.
798 -Read the documentation for your system's distribution to learn more about the specific workflow for recompiling the
799 -kernel, ensuring that you set all the necessary
800 -
801 -- [Ubuntu](https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel)
802 -- [Debian](https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official)
803 -- [Fedora](https://fedoraproject.org/wiki/Building_a_custom_kernel)
804 -- [CentOS](https://wiki.centos.org/HowTos/Custom_Kernel)
805 -- [Arch Linux](https://wiki.archlinux.org/index.php/Kernel/Traditional_compilation)
806 -- [Slackware](https://docs.slackware.com/howtos:slackware_admin:kernelbuilding)
807 -
808 -### Mount `debugfs` and `tracefs`
809 -
810 -The eBPF collector also requires both the `tracefs` and `debugfs` filesystems. Try mounting the `tracefs` and `debugfs`
811 -filesystems using the commands below:
812 -
813 -```bash
814 -sudo mount -t debugfs nodev /sys/kernel/debug
815 -sudo mount -t tracefs nodev /sys/kernel/tracing
816 -```
817 -
818 -If they are already mounted, you will see an error. You can also configure your system's `/etc/fstab` configuration to
819 -mount these filesystems on startup. More information can be found in
820 -the [ftrace documentation](https://www.kernel.org/doc/Documentation/trace/ftrace.txt).
821 -
822 -## Performance
860 +### Performance opimization
861
862 eBPF monitoring is complex and produces a large volume of metrics. We've discovered scenarios where the eBPF plugin
863 significantly increases kernel memory usage by several hundred MB.
@@ -832,7 +870,7 @@ usage (see the `system.ram` chart) has dropped significantly.
870 Beginning with `v1.31`, kernel memory usage is configurable via the [`pid table size` setting](#ebpf-load-mode)
871 in `ebpf.conf`.
872
835 -## SELinux
873 +### SELinux
874
875 When [SELinux](https://www.redhat.com/en/topics/linux/what-is-selinux) is enabled, it may prevent `ebpf.plugin` from
876 starting correctly. Check the Agent's `error.log` file for errors like the ones below:
@@ -852,7 +890,7 @@ ess.pl" exe="/usr/libexec/netdata/plugins.d/ebpf.plugin" subj=system_u:system_r:
890
891 If you see similar errors, you will have to adjust SELinux's policies to enable the eBPF collector.
892
855 -### Creation of bpf policies
893 +#### Creation of bpf policies
894
895 To enable `ebpf.plugin` to run on a distribution with SELinux enabled, it will be necessary to take the following
896 actions.
@@ -898,14 +936,14 @@ Finally, you can load the new policy and start the Netdata agent again:
936 # systemctl start netdata
937 ```
938
901 -## Lockdown
939 +### Linux kernel lockdown
940
941 Beginning with [version 5.4](https://www.zdnet.com/article/linux-to-get-kernel-lockdown-feature/), the Linux kernel has
942 a feature called "lockdown," which may affect `ebpf.plugin` depending how the kernel was compiled. The following table
943 shows how the lockdown module impacts `ebpf.plugin` based on the selected options:
944
945 | Enforcing kernel lockdown | Enable lockdown LSM early in init | Default lockdown mode | Can `ebpf.plugin` run with this? |
908 -|:------------------------- |:--------------------------------- |:--------------------- |:-------------------------------- |
946 +| :------------------------ | :-------------------------------- | :-------------------- | :------------------------------- |
947 | YES | NO | NO | YES |
948 | YES | Yes | None | YES |
949 | YES | Yes | Integrity | YES |
@@ -913,5 +951,3 @@ shows how the lockdown module impacts `ebpf.plugin` based on the selected option
951
952 If you or your distribution compiled the kernel with the last combination, your system cannot load shared libraries
953 required to run `ebpf.plugin`.
916 -
917 -