| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_EBPF_FD_H |
| 4 | #define NETDATA_EBPF_FD_H 1 |
| 5 | |
| 6 | #include "libnetdata/libnetdata.h" |
| 7 | #include "collectors/collectors-ipc/ebpf-ipc.h" |
| 8 | #include "libbpf_api/ebpf.h" |
| 9 | |
| 10 | // Module name & File description |
| 11 | #define NETDATA_EBPF_MODULE_NAME_FD "filedescriptor" |
| 12 | #define NETDATA_EBPF_FD_MODULE_DESC \ |
| 13 | "Monitor when files are open and closed. This thread is integrated with apps and cgroup." |
| 14 | |
| 15 | // Menu group |
| 16 | #define NETDATA_FILE_GROUP "file_access" |
| 17 | |
| 18 | // Global chart name |
| 19 | #define NETDATA_FILE_OPEN_CLOSE_COUNT "file_descriptor" |
| 20 | #define NETDATA_FILE_OPEN_ERR_COUNT "file_error" |
| 21 | |
| 22 | // Charts created on Apps submenu |
| 23 | #define NETDATA_SYSCALL_APPS_FILE_OPEN "file_open" |
| 24 | #define NETDATA_SYSCALL_APPS_FILE_CLOSED "file_closed" |
| 25 | #define NETDATA_SYSCALL_APPS_FILE_OPEN_ERROR "file_open_error" |
| 26 | #define NETDATA_SYSCALL_APPS_FILE_CLOSE_ERROR "file_close_error" |
| 27 | |
| 28 | // Process configuration name |
| 29 | #define NETDATA_FD_CONFIG_FILE "fd.conf" |
| 30 | |
| 31 | // Contexts |
| 32 | #define NETDATA_FS_FILEDESCRIPTOR_CONTEXT "filesystem.file_descriptor" |
| 33 | #define NETDATA_FS_FILEDESCRIPTOR_ERROR_CONTEXT "filesystem.file_error" |
| 34 | |
| 35 | #define NETDATA_CGROUP_FD_OPEN_CONTEXT "cgroup.fd_open" |
| 36 | #define NETDATA_CGROUP_FD_OPEN_ERR_CONTEXT "cgroup.fd_open_error" |
| 37 | #define NETDATA_CGROUP_FD_CLOSE_CONTEXT "cgroup.fd_close" |
| 38 | #define NETDATA_CGROUP_FD_CLOSE_ERR_CONTEXT "cgroup.fd_close_error" |
| 39 | |
| 40 | #define NETDATA_SYSTEMD_FD_OPEN_CONTEXT "systemd.service.fd_open" |
| 41 | #define NETDATA_SYSTEMD_FD_OPEN_ERR_CONTEXT "systemd.service.fd_open_error" |
| 42 | #define NETDATA_SYSTEMD_FD_CLOSE_CONTEXT "systemd.service.fd_close" |
| 43 | #define NETDATA_SYSTEMD_FD_CLOSE_ERR_CONTEXT "systemd.service.fd_close_error" |
| 44 | |
| 45 | // Chart priorities |
| 46 | #define NETDATA_EBPF_FD_CHART_PRIORITY_OPEN 20270 |
| 47 | #define NETDATA_EBPF_FD_CHART_PRIORITY_OPEN_ERR 20271 |
| 48 | #define NETDATA_EBPF_FD_CHART_PRIORITY_CLOSE 20272 |
| 49 | #define NETDATA_EBPF_FD_CHART_PRIORITY_CLOSE_ERR 20273 |
| 50 | |
| 51 | #define NETDATA_EBPF_FD_CHART_PRIORITY_CGROUP_OPEN 5400 |
| 52 | #define NETDATA_EBPF_FD_CHART_PRIORITY_CGROUP_OPEN_ERR 5401 |
| 53 | #define NETDATA_EBPF_FD_CHART_PRIORITY_CGROUP_CLOSE 5402 |
| 54 | #define NETDATA_EBPF_FD_CHART_PRIORITY_CGROUP_CLOSE_ERR 5403 |
| 55 | |
| 56 | #define NETDATA_EBPF_FD_CHART_PRIORITY_APPS_OPEN 20220 |
| 57 | #define NETDATA_EBPF_FD_CHART_PRIORITY_APPS_OPEN_ERR 20221 |
| 58 | #define NETDATA_EBPF_FD_CHART_PRIORITY_APPS_CLOSE 20222 |
| 59 | #define NETDATA_EBPF_FD_CHART_PRIORITY_APPS_CLOSE_ERR 20223 |
| 60 | |
| 61 | // ARAL name |
| 62 | #define NETDATA_EBPF_FD_ARAL_NAME "ebpf_fd" |
| 63 | |
| 64 | enum fd_tables { |
| 65 | NETDATA_FD_PID_STATS, |
| 66 | NETDATA_FD_GLOBAL_STATS, |
| 67 | |
| 68 | // Keep this as last and don't skip numbers as it is used as element counter |
| 69 | NETDATA_FD_CONTROLLER |
| 70 | }; |
| 71 | |
| 72 | enum fd_counters { |
| 73 | NETDATA_KEY_CALLS_DO_SYS_OPEN, |
| 74 | NETDATA_KEY_ERROR_DO_SYS_OPEN, |
| 75 | |
| 76 | NETDATA_KEY_CALLS_CLOSE_FD, |
| 77 | NETDATA_KEY_ERROR_CLOSE_FD, |
| 78 | |
| 79 | // Keep this as last and don't skip numbers as it is used as element counter |
| 80 | NETDATA_FD_COUNTER |
| 81 | }; |
| 82 | |
| 83 | enum fd_syscalls { |
| 84 | NETDATA_FD_SYSCALL_OPEN, |
| 85 | NETDATA_FD_SYSCALL_CLOSE, |
| 86 | |
| 87 | // Keep this as last and don't skip numbers as it is used as element counter |
| 88 | NETDATA_FD_SYSCALL_END |
| 89 | }; |
| 90 | |
| 91 | enum fd_close_syscall { |
| 92 | NETDATA_FD_CLOSE_FD, |
| 93 | NETDATA_FD___CLOSE_FD, |
| 94 | |
| 95 | // Keep this as last and don't skip numbers as it is used as element counter |
| 96 | NETDATA_FD_CLOSE_END |
| 97 | }; |
| 98 | |
| 99 | #define NETDATA_EBPF_MAX_FD_TARGETS 2 |
| 100 | |
| 101 | void ebpf_fd_thread(void *ptr); |
| 102 | void ebpf_fd_create_apps_charts(struct ebpf_module *em, void *ptr); |
| 103 | extern struct config fd_config; |
| 104 | extern netdata_ebpf_targets_t fd_targets[]; |
| 105 | |
| 106 | #endif /* NETDATA_EBPF_FD_H */ |