| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_COLLECTOR_EBPF_LIBRARY_H |
| 4 | #define NETDATA_COLLECTOR_EBPF_LIBRARY_H 1 |
| 5 | |
| 6 | #include <stdint.h> |
| 7 | #include "../ebpf_socket_ipc.h" |
| 8 | |
| 9 | typedef struct netdata_publish_syscall netdata_publish_syscall_t; |
| 10 | typedef struct netdata_syscall_stat netdata_syscall_stat_t; |
| 11 | typedef struct ebpf_module ebpf_module_t; |
| 12 | typedef struct ebpf_target ebpf_target_t; |
| 13 | typedef struct ebpf_tracepoint ebpf_tracepoint_t; |
| 14 | typedef struct aral ARAL; |
| 15 | typedef struct config config; |
| 16 | |
| 17 | /***************************************************************** |
| 18 | * |
| 19 | * DIMENSION WRITING FUNCTIONS |
| 20 | * |
| 21 | *****************************************************************/ |
| 22 | |
| 23 | void write_chart_dimension(const char *dim, long long value); |
| 24 | void ebpf_write_global_dimension(char *name, char *id, char *algorithm); |
| 25 | void ebpf_create_global_dimension(void *ptr, int end); |
| 26 | |
| 27 | /***************************************************************** |
| 28 | * |
| 29 | * CHART WRITING FUNCTIONS |
| 30 | * |
| 31 | *****************************************************************/ |
| 32 | |
| 33 | void write_count_chart(char *name, char *family, netdata_publish_syscall_t *move, uint32_t end); |
| 34 | void write_err_chart(char *name, char *family, netdata_publish_syscall_t *move, int end); |
| 35 | void ebpf_one_dimension_write_charts(char *family, char *chart, char *dim, long long v1); |
| 36 | void write_io_chart(char *chart, char *family, char *dwrite, long long vwrite, char *dread, long long vread); |
| 37 | void write_histogram_chart(char *family, char *name, const uint64_t *hist, char **dimensions, uint32_t end); |
| 38 | |
| 39 | /***************************************************************** |
| 40 | * |
| 41 | * CHART CREATION FUNCTIONS |
| 42 | * |
| 43 | *****************************************************************/ |
| 44 | |
| 45 | void ebpf_write_chart_cmd( |
| 46 | char *type, |
| 47 | char *id, |
| 48 | char *suffix, |
| 49 | char *title, |
| 50 | char *units, |
| 51 | char *family, |
| 52 | char *charttype, |
| 53 | char *context, |
| 54 | int order, |
| 55 | int update_every, |
| 56 | char *module); |
| 57 | |
| 58 | void ebpf_write_chart_obsolete( |
| 59 | char *type, |
| 60 | const char *id, |
| 61 | char *suffix, |
| 62 | char *title, |
| 63 | char *units, |
| 64 | char *family, |
| 65 | char *charttype, |
| 66 | const char *context, |
| 67 | int order, |
| 68 | int update_every); |
| 69 | |
| 70 | void ebpf_create_chart( |
| 71 | char *type, |
| 72 | char *id, |
| 73 | char *title, |
| 74 | char *units, |
| 75 | char *family, |
| 76 | char *context, |
| 77 | char *charttype, |
| 78 | int order, |
| 79 | void (*ncd)(void *, int), |
| 80 | void *move, |
| 81 | int end, |
| 82 | int update_every, |
| 83 | char *module); |
| 84 | |
| 85 | /***************************************************************** |
| 86 | * |
| 87 | * ARAL STATISTIC CHARTS |
| 88 | * |
| 89 | *****************************************************************/ |
| 90 | |
| 91 | int ebpf_statistic_create_aral_chart(char *name, ebpf_module_t *em); |
| 92 | void ebpf_statistic_obsolete_aral_chart(ebpf_module_t *em, int prio); |
| 93 | void ebpf_send_data_aral_chart(ARAL *memory, ebpf_module_t *em); |
| 94 | |
| 95 | /***************************************************************** |
| 96 | * |
| 97 | * CONFIG FILE PARSER FUNCTIONS |
| 98 | * |
| 99 | *****************************************************************/ |
| 100 | |
| 101 | void ebpf_how_to_load(const char *ptr); |
| 102 | void ebpf_set_apps_mode(netdata_apps_integration_flags_t value); |
| 103 | void ebpf_update_interval(int update_every); |
| 104 | void ebpf_update_table_size(); |
| 105 | void ebpf_update_lifetime(); |
| 106 | void ebpf_set_load_mode(netdata_ebpf_load_mode_t load, netdata_ebpf_load_mode_t origin); |
| 107 | void ebpf_update_load_mode(const char *str, netdata_ebpf_load_mode_t origin); |
| 108 | void ebpf_update_map_per_core(); |
| 109 | void ebpf_set_ipc_value(const char *integration); |
| 110 | void ebpf_parse_ipc_section(); |
| 111 | void ebpf_set_thread_mode(netdata_run_mode_t lmode); |
| 112 | void ebpf_enable_chart(int idx, int disable_cgroup); |
| 113 | void ebpf_enable_specific_chart(ebpf_module_t *em, int disable_cgroup); |
| 114 | void read_collector_values(int *disable_cgroups, int update_every, netdata_ebpf_load_mode_t origin); |
| 115 | void parse_network_viewer_section(struct config *cfg); |
| 116 | void ebpf_parse_service_name_section(struct config *cfg); |
| 117 | void ebpf_parse_ports(const char *ptr); |
| 118 | void ebpf_parse_ips_unsafe(const char *ptr); |
| 119 | void ebpf_read_local_addresses_unsafe(); |
| 120 | int ebpf_load_collector_config(char *path, int *disable_cgroups, int update_every); |
| 121 | void ebpf_load_thread_config(); |
| 122 | |
| 123 | /***************************************************************** |
| 124 | * |
| 125 | * FUNCTIONS TO CREATE CHARTS |
| 126 | * |
| 127 | *****************************************************************/ |
| 128 | |
| 129 | void ebpf_create_apps_for_module(ebpf_module_t *em, ebpf_target_t *root); |
| 130 | void ebpf_create_apps_charts(ebpf_target_t *root); |
| 131 | |
| 132 | /***************************************************************** |
| 133 | * |
| 134 | * FUNCTIONS TO READ GLOBAL HASH TABLES |
| 135 | * |
| 136 | *****************************************************************/ |
| 137 | |
| 138 | void ebpf_read_global_table_stats( |
| 139 | netdata_idx_t *stats, |
| 140 | netdata_idx_t *values, |
| 141 | int map_fd, |
| 142 | int maps_per_core, |
| 143 | uint32_t begin, |
| 144 | uint32_t end); |
| 145 | |
| 146 | /***************************************************************** |
| 147 | * |
| 148 | * FUNCTIONS TO DEFINE OPTIONS |
| 149 | * |
| 150 | *****************************************************************/ |
| 151 | |
| 152 | void ebpf_global_labels( |
| 153 | netdata_syscall_stat_t *is, |
| 154 | netdata_publish_syscall_t *pio, |
| 155 | char **dim, |
| 156 | char **name, |
| 157 | int *algorithm, |
| 158 | int end); |
| 159 | |
| 160 | void disable_all_global_charts(); |
| 161 | void ebpf_disable_cgroups(); |
| 162 | void ebpf_update_disabled_plugin_stats(ebpf_module_t *em); |
| 163 | void ebpf_print_help(); |
| 164 | |
| 165 | /***************************************************************** |
| 166 | * |
| 167 | * TRACEPOINT MANAGEMENT FUNCTIONS |
| 168 | * |
| 169 | *****************************************************************/ |
| 170 | |
| 171 | int ebpf_enable_tracepoint(ebpf_tracepoint_t *tp); |
| 172 | int ebpf_disable_tracepoint(ebpf_tracepoint_t *tp); |
| 173 | uint32_t ebpf_enable_tracepoints(ebpf_tracepoint_t *tps); |
| 174 | |
| 175 | /***************************************************************** |
| 176 | * |
| 177 | * AUXILIARY FUNCTIONS USED DURING INITIALIZATION |
| 178 | * |
| 179 | *****************************************************************/ |
| 180 | |
| 181 | void read_local_ports(char *filename, uint8_t proto); |
| 182 | |
| 183 | #endif /* NETDATA_COLLECTOR_EBPF_LIBRARY_H */ |