@cryptotaxi247 / netdata-1 / commits / b75431762

Change eBPF plugin internal (#10442)

Remove unused variables.

thiagoftsm committed Feb 11, 2021 at 12:38 UTC b7543176283b6e555aab14c131cccb4c54767725
10 files changed +224 -224
collectors/ebpf.plugin/ebpf.c
+36 -12
@@ -56,6 +56,7 @@ char *ebpf_user_config_dir = CONFIG_DIR;
56 char *ebpf_stock_config_dir = LIBCONFIG_DIR;
57 static char *ebpf_configured_log_dir = LOG_DIR;
58
59 +char *ebpf_algorithms[] = {"absolute", "incremental"};
60 int update_every = 1;
61 static int thread_finished = 0;
62 int close_ebpf_plugin = 0;
@@ -99,6 +100,19 @@ ebpf_network_viewer_options_t network_viewer_opt;
100 *
101 *****************************************************************/
102
103 +/**
104 + * Cleanup publish syscall
105 + *
106 + * @param nps list of structures to clean
107 + */
108 +void ebpf_cleanup_publish_syscall(netdata_publish_syscall_t *nps)
109 +{
110 + while (nps) {
111 + freez(nps->algorithm);
112 + nps = nps->next;
113 + }
114 +}
115 +
116 /**
117 * Clean port Structure
118 *
@@ -307,17 +321,21 @@ void write_err_chart(char *name, char *family, netdata_publish_syscall_t *move,
321 /**
322 * Call the necessary functions to create a chart.
323 *
324 + * @param chart the chart name
325 * @param family the chart family
311 - * @param move the pointer with the values that will be published
326 + * @param dwrite the dimension name
327 + * @param vwrite the value for previous dimension
328 + * @param dread the dimension name
329 + * @param vread the value for previous dimension
330 *
331 * @return It returns a variable tha maps the charts that did not have zero values.
332 */
315 -void write_io_chart(char *chart, char *family, char *dwrite, char *dread, netdata_publish_vfs_common_t *pvc)
333 +void write_io_chart(char *chart, char *family, char *dwrite, long long vwrite, char *dread, long long vread)
334 {
335 write_begin_chart(family, chart);
336
319 - write_chart_dimension(dwrite, (long long)pvc->write);
320 - write_chart_dimension(dread, (long long)pvc->read);
337 + write_chart_dimension(dwrite, vwrite);
338 + write_chart_dimension(dread, vread);
339
340 write_end_chart();
341 }
@@ -349,12 +367,13 @@ void ebpf_write_chart_cmd(char *type, char *id, char *title, char *units, char *
367 /**
368 * Write the dimension command on standard output
369 *
352 - * @param n the dimension name
353 - * @param d the dimension information
370 + * @param name the dimension name
371 + * @param id the dimension id
372 + * @param algo the dimension algorithm
373 */
355 -void ebpf_write_global_dimension(char *n, char *d)
374 +void ebpf_write_global_dimension(char *name, char *id, char *algorithm)
375 {
357 - printf("DIMENSION %s %s absolute 1 1\n", n, d);
376 + printf("DIMENSION %s %s %s 1 1\n", name, id, algorithm);
377 }
378
379 /**
@@ -369,7 +388,7 @@ void ebpf_create_global_dimension(void *ptr, int end)
388
389 int i = 0;
390 while (move && i < end) {
372 - ebpf_write_global_dimension(move->name, move->dimension);
391 + ebpf_write_global_dimension(move->name, move->dimension, move->algorithm);
392
393 move = move->next;
394 i++;
@@ -411,16 +430,18 @@ void ebpf_create_chart(char *type,
430 * @param units the value displayed on vertical axis.
431 * @param family Submenu that the chart will be attached on dashboard.
432 * @param order the chart order
433 + * @param algorithm the algorithm used by dimension
434 * @param root structure used to create the dimensions.
435 */
416 -void ebpf_create_charts_on_apps(char *id, char *title, char *units, char *family, int order, struct target *root)
436 +void ebpf_create_charts_on_apps(char *id, char *title, char *units, char *family, int order,
437 + char *algorithm, struct target *root)
438 {
439 struct target *w;
440 ebpf_write_chart_cmd(NETDATA_APPS_FAMILY, id, title, units, family, "stacked", order);
441
442 for (w = root; w; w = w->next) {
443 if (unlikely(w->exposed))
423 - fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", w->name);
444 + fprintf(stdout, "DIMENSION %s '' %s 1 1\n", w->name, algorithm);
445 }
446 }
447
@@ -437,9 +458,11 @@ void ebpf_create_charts_on_apps(char *id, char *title, char *units, char *family
458 * @param pio structure used to generate charts.
459 * @param dim a pointer for the dimensions name
460 * @param name a pointer for the tensor with the name of the functions.
461 + * @param algorithm a vector with the algorithms used to make the charts
462 * @param end the number of elements in the previous 4 arguments.
463 */
442 -void ebpf_global_labels(netdata_syscall_stat_t *is, netdata_publish_syscall_t *pio, char **dim, char **name, int end)
464 +void ebpf_global_labels(netdata_syscall_stat_t *is, netdata_publish_syscall_t *pio, char **dim,
465 + char **name, int *algorithm, int end)
466 {
467 int i;
468
@@ -453,6 +476,7 @@ void ebpf_global_labels(netdata_syscall_stat_t *is, netdata_publish_syscall_t *p
476
477 pio[i].dimension = dim[i];
478 pio[i].name = name[i];
479 + pio[i].algorithm = strdupz(ebpf_algorithms[algorithm[i]]);
480 if (publish_prev) {
481 publish_prev->next = &pio[i];
482 }
collectors/ebpf.plugin/ebpf.h
+16 -3
@@ -43,6 +43,7 @@ typedef uint64_t netdata_idx_t;
43 typedef struct netdata_publish_syscall {
44 char *dimension;
45 char *name;
46 + char *algorithm;
47 unsigned long nbyte;
48 unsigned long pbyte;
49 uint64_t ncall;
@@ -98,6 +99,11 @@ extern ebpf_module_t ebpf_modules[];
99 #define EBPF_SYS_CLONE_IDX 11
100 #define EBPF_MAX_MAPS 32
101
102 +enum ebpf_algorithms_list {
103 + NETDATA_EBPF_ABSOLUTE_IDX,
104 + NETDATA_EBPF_INCREMENTAL_IDX
105 +};
106 +
107 // Threads
108 extern void *ebpf_process_thread(void *ptr);
109 extern void *ebpf_socket_thread(void *ptr);
@@ -118,6 +124,7 @@ extern void ebpf_global_labels(netdata_syscall_stat_t *is,
124 netdata_publish_syscall_t *pio,
125 char **dim,
126 char **name,
127 + int *algorithm,
128 int end);
129
130 extern void ebpf_write_chart_cmd(char *type,
@@ -128,7 +135,7 @@ extern void ebpf_write_chart_cmd(char *type,
135 char *charttype,
136 int order);
137
131 -extern void ebpf_write_global_dimension(char *n, char *d);
138 +extern void ebpf_write_global_dimension(char *name, char *id, char *algorithm);
139
140 extern void ebpf_create_global_dimension(void *ptr, int end);
141
@@ -150,7 +157,8 @@ extern void write_count_chart(char *name, char *family, netdata_publish_syscall_
157
158 extern void write_err_chart(char *name, char *family, netdata_publish_syscall_t *move, int end);
159
153 -extern void write_io_chart(char *chart, char *family, char *dwrite, char *dread, netdata_publish_vfs_common_t *pvc);
160 +extern void write_io_chart(char *chart, char *family, char *dwrite, long long vwrite,
161 + char *dread, long long vread);
162
163 extern void fill_ebpf_data(ebpf_data_t *ef);
164
@@ -159,17 +167,21 @@ extern void ebpf_create_charts_on_apps(char *name,
167 char *units,
168 char *family,
169 int order,
170 + char *algorithm,
171 struct target *root);
172
173 extern void write_end_chart();
174
175 +extern void ebpf_cleanup_publish_syscall(netdata_publish_syscall_t *nps);
176 +
177 #define EBPF_GLOBAL_SECTION "global"
178 #define EBPF_PROGRAMS_SECTION "ebpf programs"
179 #define EBPF_NETWORK_VIEWER_SECTION "network connections"
180 #define EBPF_SERVICE_NAME_SECTION "service name"
181
182 #define EBPF_COMMON_DIMENSION_CALL "calls/s"
172 -#define EBPF_COMMON_DIMENSION_BYTESS "bytes/s"
183 +#define EBPF_COMMON_DIMENSION_BITS "kilobits/s"
184 +#define EBPF_COMMON_DIMENSION_BYTES "bytes/s"
185 #define EBPF_COMMON_DIMENSION_DIFFERENCE "difference"
186 #define EBPF_COMMON_DIMENSION_PACKETS "packets"
187
@@ -178,6 +190,7 @@ extern char *ebpf_user_config_dir;
190 extern char *ebpf_stock_config_dir;
191 extern int debug_enabled;
192 extern struct pid_stat *root_of_pids;
193 +extern char *ebpf_algorithms[];
194
195 // Socket functions and variables
196 // Common functions
collectors/ebpf.plugin/ebpf_apps.c
-4
@@ -931,13 +931,11 @@ void cleanup_exited_pids()
931
932 freez(current_apps_data[r]);
933 current_apps_data[r] = NULL;
934 - prev_apps_data[r] = NULL;
934
935 // Clean socket structures
936 if (socket_bandwidth_curr) {
937 freez(socket_bandwidth_curr[r]);
938 socket_bandwidth_curr[r] = NULL;
940 - socket_bandwidth_prev[r] = NULL;
939 }
940 } else {
941 if (unlikely(p->keep))
@@ -1055,13 +1053,11 @@ void collect_data_for_all_processes(int tbl_pid_stats_fd)
1053
1054 freez(current_apps_data[key]);
1055 current_apps_data[key] = NULL;
1058 - prev_apps_data[key] = NULL;
1056
1057 // Clean socket structures
1058 if (socket_bandwidth_curr) {
1059 freez(socket_bandwidth_curr[key]);
1060 socket_bandwidth_curr[key] = NULL;
1064 - socket_bandwidth_prev[key] = NULL;
1061 }
1062
1063 pids = pids->next;
collectors/ebpf.plugin/ebpf_apps.h
-1
@@ -426,6 +426,5 @@ extern void collect_data_for_all_processes(int tbl_pid_stats_fd);
426
427 extern ebpf_process_stat_t **global_process_stats;
428 extern ebpf_process_publish_apps_t **current_apps_data;
429 -extern ebpf_process_publish_apps_t **prev_apps_data;
429
430 #endif /* NETDATA_EBPF_APPS_H */
collectors/ebpf.plugin/ebpf_process.c
+102 -116
@@ -11,9 +11,9 @@
11 *
12 *****************************************************************/
13
14 -static char *process_dimension_names[NETDATA_MAX_MONITOR_VECTOR] = { "open", "close", "delete", "read", "write",
14 +static char *process_dimension_names[NETDATA_KEY_PUBLISH_PROCESS_END] = { "open", "close", "delete", "read", "write",
15 "process", "task", "process", "thread" };
16 -static char *process_id_names[NETDATA_MAX_MONITOR_VECTOR] = { "do_sys_open", "__close_fd", "vfs_unlink",
16 +static char *process_id_names[NETDATA_KEY_PUBLISH_PROCESS_END] = { "do_sys_open", "__close_fd", "vfs_unlink",
17 "vfs_read", "vfs_write", "do_exit",
18 "release_task", "_do_fork", "sys_clone" };
19 static char *status[] = { "process", "zombie" };
@@ -26,7 +26,6 @@ static ebpf_data_t process_data;
26
27 ebpf_process_stat_t **global_process_stats = NULL;
28 ebpf_process_publish_apps_t **current_apps_data = NULL;
29 -ebpf_process_publish_apps_t **prev_apps_data = NULL;
29
30 int process_enabled = 0;
31
@@ -51,67 +50,36 @@ static void ebpf_update_global_publish(
50 netdata_publish_syscall_t *publish, netdata_publish_vfs_common_t *pvc, netdata_syscall_stat_t *input)
51 {
52 netdata_publish_syscall_t *move = publish;
53 + int selector = NETDATA_KEY_PUBLISH_PROCESS_OPEN;
54 while (move) {
55 - if (input->call != move->pcall) {
56 - //This condition happens to avoid initial values with dimensions higher than normal values.
57 - if (move->pcall) {
58 - move->ncall = (input->call > move->pcall) ? input->call - move->pcall : move->pcall - input->call;
59 - move->nbyte = (input->bytes > move->pbyte) ? input->bytes - move->pbyte : move->pbyte - input->bytes;
60 - move->nerr = (input->ecall > move->nerr) ? input->ecall - move->perr : move->perr - input->ecall;
61 - } else {
62 - move->ncall = 0;
63 - move->nbyte = 0;
64 - move->nerr = 0;
65 - }
55 + // Until NETDATA_KEY_PUBLISH_PROCESS_READ we are creating accumulators, so it is possible
56 + // to use incremental charts, but after this we will do some math with the values, so we are storing
57 + // absolute values
58 + if (selector < NETDATA_KEY_PUBLISH_PROCESS_READ) {
59 + move->ncall = input->call;
60 + move->nbyte = input->bytes;
61 + move->nerr = input->ecall;
62 + } else {
63 + move->ncall = (input->call > move->pcall) ? input->call - move->pcall : move->pcall - input->call;
64 + move->nbyte = (input->bytes > move->pbyte) ? input->bytes - move->pbyte : move->pbyte - input->bytes;
65 + move->nerr = (input->ecall > move->nerr) ? input->ecall - move->perr : move->perr - input->ecall;
66
67 move->pcall = input->call;
68 move->pbyte = input->bytes;
69 move->perr = input->ecall;
70 - } else {
71 - move->ncall = 0;
72 - move->nbyte = 0;
73 - move->nerr = 0;
70 }
71
72 input = input->next;
73 move = move->next;
74 + selector++;
75 }
76
80 - pvc->write = -((long)publish[2].nbyte);
81 - pvc->read = (long)publish[3].nbyte;
82 -
83 - pvc->running = (long)publish[7].ncall - (long)publish[8].ncall;
84 - publish[6].ncall = -publish[6].ncall; // release
85 - pvc->zombie = (long)publish[5].ncall + (long)publish[6].ncall;
86 -}
87 -
88 -/**
89 - * Update apps dimension to publish.
90 - *
91 - * @param curr Last values read from memory.
92 - * @param prev Previous values read from memory.
93 - * @param first was it allocated now?
94 - */
95 -static void
96 -ebpf_process_update_apps_publish(ebpf_process_publish_apps_t *curr, ebpf_process_publish_apps_t *prev, int first)
97 -{
98 - if (first)
99 - return;
77 + pvc->write = -((long)publish[NETDATA_KEY_PUBLISH_PROCESS_WRITE].nbyte);
78 + pvc->read = (long)publish[NETDATA_KEY_PUBLISH_PROCESS_READ].nbyte;
79
101 - curr->publish_open = curr->call_sys_open - prev->call_sys_open;
102 - curr->publish_closed = curr->call_close_fd - prev->call_close_fd;
103 - curr->publish_deleted = curr->call_vfs_unlink - prev->call_vfs_unlink;
104 - curr->publish_write_call = curr->call_write - prev->call_write;
105 - curr->publish_write_bytes = curr->bytes_written - prev->bytes_written;
106 - curr->publish_read_call = curr->call_read - prev->call_read;
107 - curr->publish_read_bytes = curr->bytes_read - prev->bytes_read;
108 - curr->publish_process = curr->call_do_fork - prev->call_do_fork;
109 - curr->publish_thread = curr->call_sys_clone - prev->call_sys_clone;
110 - curr->publish_task = curr->call_release_task - prev->call_release_task;
111 - curr->publish_open_error = curr->ecall_sys_open - prev->ecall_sys_open;
112 - curr->publish_close_error = curr->ecall_close_fd - prev->ecall_close_fd;
113 - curr->publish_write_error = curr->ecall_write - prev->ecall_write;
114 - curr->publish_read_error = curr->ecall_read - prev->ecall_read;
80 + pvc->running = (long)publish[NETDATA_KEY_PUBLISH_PROCESS_FORK].ncall - (long)publish[NETDATA_KEY_PUBLISH_PROCESS_CLONE].ncall;
81 + publish[NETDATA_KEY_PUBLISH_PROCESS_RELEASE_TASK].ncall = -publish[NETDATA_KEY_PUBLISH_PROCESS_RELEASE_TASK].ncall;
82 + pvc->zombie = (long)publish[NETDATA_KEY_PUBLISH_PROCESS_EXIT].ncall + (long)publish[NETDATA_KEY_PUBLISH_PROCESS_RELEASE_TASK].ncall;
83 }
84
85 /**
@@ -164,7 +132,9 @@ static void ebpf_process_send_data(ebpf_module_t *em)
132 NETDATA_PROCESS_ERROR_NAME, NETDATA_EBPF_FAMILY, &process_publish_aggregated[NETDATA_PROCESS_START], 2);
133 }
134
167 - write_io_chart(NETDATA_VFS_IO_FILE_BYTES, NETDATA_EBPF_FAMILY, process_id_names[3], process_id_names[4], &pvc);
135 + write_io_chart(NETDATA_VFS_IO_FILE_BYTES, NETDATA_EBPF_FAMILY,
136 + process_id_names[NETDATA_KEY_PUBLISH_PROCESS_WRITE], (long long) pvc.write,
137 + process_id_names[NETDATA_KEY_PUBLISH_PROCESS_READ], (long long)pvc.read);
138 }
139
140 /**
@@ -230,7 +200,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
200 write_begin_chart(NETDATA_APPS_FAMILY, NETDATA_SYSCALL_APPS_FILE_OPEN);
201 for (w = root; w; w = w->next) {
202 if (unlikely(w->exposed && w->processes)) {
233 - value = ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_open));
203 + value = ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, call_sys_open));
204 write_chart_dimension(w->name, value);
205 }
206 }
@@ -241,7 +211,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
211 for (w = root; w; w = w->next) {
212 if (unlikely(w->exposed && w->processes)) {
213 value = ebpf_process_sum_values_for_pids(
244 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_open_error));
214 + w->root_pid, offsetof(ebpf_process_publish_apps_t, ecall_sys_open));
215 write_chart_dimension(w->name, value);
216 }
217 }
@@ -252,7 +222,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
222 for (w = root; w; w = w->next) {
223 if (unlikely(w->exposed && w->processes)) {
224 value =
255 - ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_closed));
225 + ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, call_close_fd));
226 write_chart_dimension(w->name, value);
227 }
228 }
@@ -263,7 +233,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
233 for (w = root; w; w = w->next) {
234 if (unlikely(w->exposed && w->processes)) {
235 value = ebpf_process_sum_values_for_pids(
266 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_close_error));
236 + w->root_pid, offsetof(ebpf_process_publish_apps_t, ecall_close_fd));
237 write_chart_dimension(w->name, value);
238 }
239 }
@@ -274,7 +244,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
244 for (w = root; w; w = w->next) {
245 if (unlikely(w->exposed && w->processes)) {
246 value =
277 - ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_deleted));
247 + ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, call_vfs_unlink));
248 write_chart_dimension(w->name, value);
249 }
250 }
@@ -284,7 +254,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
254 for (w = root; w; w = w->next) {
255 if (unlikely(w->exposed && w->processes)) {
256 value = ebpf_process_sum_values_for_pids(
287 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_write_call));
257 + w->root_pid, offsetof(ebpf_process_publish_apps_t, call_write));
258 write_chart_dimension(w->name, value);
259 }
260 }
@@ -295,7 +265,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
265 for (w = root; w; w = w->next) {
266 if (unlikely(w->exposed && w->processes)) {
267 value = ebpf_process_sum_values_for_pids(
298 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_write_error));
268 + w->root_pid, offsetof(ebpf_process_publish_apps_t, ecall_write));
269 write_chart_dimension(w->name, value);
270 }
271 }
@@ -306,7 +276,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
276 for (w = root; w; w = w->next) {
277 if (unlikely(w->exposed && w->processes)) {
278 value =
309 - ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_read_call));
279 + ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, call_read));
280 write_chart_dimension(w->name, value);
281 }
282 }
@@ -317,7 +287,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
287 for (w = root; w; w = w->next) {
288 if (unlikely(w->exposed && w->processes)) {
289 value = ebpf_process_sum_values_for_pids(
320 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_read_error));
290 + w->root_pid, offsetof(ebpf_process_publish_apps_t, ecall_read));
291 write_chart_dimension(w->name, value);
292 }
293 }
@@ -328,7 +298,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
298 for (w = root; w; w = w->next) {
299 if (unlikely(w->exposed && w->processes)) {
300 value = ebpf_process_sum_values_for_pids(
331 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_write_bytes));
301 + w->root_pid, offsetof(ebpf_process_publish_apps_t, bytes_written));
302 write_chart_dimension(w->name, value);
303 }
304 }
@@ -338,7 +308,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
308 for (w = root; w; w = w->next) {
309 if (unlikely(w->exposed && w->processes)) {
310 value = ebpf_process_sum_values_for_pids(
341 - w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_read_bytes));
311 + w->root_pid, offsetof(ebpf_process_publish_apps_t, bytes_read));
312 write_chart_dimension(w->name, value);
313 }
314 }
@@ -348,7 +318,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
318 for (w = root; w; w = w->next) {
319 if (unlikely(w->exposed && w->processes)) {
320 value =
351 - ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_process));
321 + ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, call_do_fork));
322 write_chart_dimension(w->name, value);
323 }
324 }
@@ -358,7 +328,7 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
328 for (w = root; w; w = w->next) {
329 if (unlikely(w->exposed && w->processes)) {
330 value =
361 - ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_thread));
331 + ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, call_sys_clone));
332 write_chart_dimension(w->name, value);
333 }
334 }
@@ -367,7 +337,8 @@ void ebpf_process_send_apps_data(ebpf_module_t *em, struct target *root)
337 write_begin_chart(NETDATA_APPS_FAMILY, NETDATA_SYSCALL_APPS_TASK_CLOSE);
338 for (w = root; w; w = w->next) {
339 if (unlikely(w->exposed && w->processes)) {
370 - value = ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t, publish_task));
340 + value = ebpf_process_sum_values_for_pids(w->root_pid, offsetof(ebpf_process_publish_apps_t,
341 + call_release_task));
342 write_chart_dimension(w->name, value);
343 }
344 }
@@ -405,27 +376,27 @@ static void read_hash_global_tables()
376 }
377 }
378
408 - process_aggregated_data[0].call = res[NETDATA_KEY_CALLS_DO_SYS_OPEN];
409 - process_aggregated_data[1].call = res[NETDATA_KEY_CALLS_CLOSE_FD];
410 - process_aggregated_data[2].call = res[NETDATA_KEY_CALLS_VFS_UNLINK];
411 - process_aggregated_data[3].call = res[NETDATA_KEY_CALLS_VFS_READ] + res[NETDATA_KEY_CALLS_VFS_READV];
412 - process_aggregated_data[4].call = res[NETDATA_KEY_CALLS_VFS_WRITE] + res[NETDATA_KEY_CALLS_VFS_WRITEV];
413 - process_aggregated_data[5].call = res[NETDATA_KEY_CALLS_DO_EXIT];
414 - process_aggregated_data[6].call = res[NETDATA_KEY_CALLS_RELEASE_TASK];
415 - process_aggregated_data[7].call = res[NETDATA_KEY_CALLS_DO_FORK];
416 - process_aggregated_data[8].call = res[NETDATA_KEY_CALLS_SYS_CLONE];
417 -
418 - process_aggregated_data[0].ecall = res[NETDATA_KEY_ERROR_DO_SYS_OPEN];
419 - process_aggregated_data[1].ecall = res[NETDATA_KEY_ERROR_CLOSE_FD];
420 - process_aggregated_data[2].ecall = res[NETDATA_KEY_ERROR_VFS_UNLINK];
421 - process_aggregated_data[3].ecall = res[NETDATA_KEY_ERROR_VFS_READ] + res[NETDATA_KEY_ERROR_VFS_READV];
422 - process_aggregated_data[4].ecall = res[NETDATA_KEY_ERROR_VFS_WRITE] + res[NETDATA_KEY_ERROR_VFS_WRITEV];
423 - process_aggregated_data[7].ecall = res[NETDATA_KEY_ERROR_DO_FORK];
424 - process_aggregated_data[8].ecall = res[NETDATA_KEY_ERROR_SYS_CLONE];
425 -
426 - process_aggregated_data[2].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITE] +
379 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_OPEN].call = res[NETDATA_KEY_CALLS_DO_SYS_OPEN];
380 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_CLOSE].call = res[NETDATA_KEY_CALLS_CLOSE_FD];
381 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_UNLINK].call = res[NETDATA_KEY_CALLS_VFS_UNLINK];
382 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_READ].call = res[NETDATA_KEY_CALLS_VFS_READ] + res[NETDATA_KEY_CALLS_VFS_READV];
383 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_WRITE].call = res[NETDATA_KEY_CALLS_VFS_WRITE] + res[NETDATA_KEY_CALLS_VFS_WRITEV];
384 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_EXIT].call = res[NETDATA_KEY_CALLS_DO_EXIT];
385 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_RELEASE_TASK].call = res[NETDATA_KEY_CALLS_RELEASE_TASK];
386 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_FORK].call = res[NETDATA_KEY_CALLS_DO_FORK];
387 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_CLONE].call = res[NETDATA_KEY_CALLS_SYS_CLONE];
388 +
389 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_OPEN].ecall = res[NETDATA_KEY_ERROR_DO_SYS_OPEN];
390 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_CLOSE].ecall = res[NETDATA_KEY_ERROR_CLOSE_FD];
391 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_UNLINK].ecall = res[NETDATA_KEY_ERROR_VFS_UNLINK];
392 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_READ].ecall = res[NETDATA_KEY_ERROR_VFS_READ] + res[NETDATA_KEY_ERROR_VFS_READV];
393 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_WRITE].ecall = res[NETDATA_KEY_ERROR_VFS_WRITE] + res[NETDATA_KEY_ERROR_VFS_WRITEV];
394 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_FORK].ecall = res[NETDATA_KEY_ERROR_DO_FORK];
395 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_CLONE].ecall = res[NETDATA_KEY_ERROR_SYS_CLONE];
396 +
397 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_WRITE].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITE] +
398 (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITEV];
428 - process_aggregated_data[3].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_READ] +
399 + process_aggregated_data[NETDATA_KEY_PUBLISH_PROCESS_READ].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_READ] +
400 (uint64_t)res[NETDATA_KEY_BYTES_VFS_READV];
401 }
402
@@ -444,18 +415,9 @@ static void ebpf_process_update_apps_data()
415 }
416
417 ebpf_process_publish_apps_t *cad = current_apps_data[current_pid];
447 - ebpf_process_publish_apps_t *pad = prev_apps_data[current_pid];
448 - int lstatus;
418 if (!cad) {
450 - ebpf_process_publish_apps_t *ptr = callocz(2, sizeof(ebpf_process_publish_apps_t));
451 - cad = &ptr[0];
419 + cad = callocz(1, sizeof(ebpf_process_publish_apps_t));
420 current_apps_data[current_pid] = cad;
453 - pad = &ptr[1];
454 - prev_apps_data[current_pid] = pad;
455 - lstatus = 1;
456 - } else {
457 - memcpy(pad, cad, sizeof(ebpf_process_publish_apps_t));
458 - lstatus = 0;
421 }
422
423 //Read data
@@ -480,8 +442,6 @@ static void ebpf_process_update_apps_data()
442 cad->bytes_written = (uint64_t)ps->write_bytes + (uint64_t)ps->write_bytes;
443 cad->bytes_read = (uint64_t)ps->read_bytes + (uint64_t)ps->readv_bytes;
444
483 - ebpf_process_update_apps_publish(cad, pad, lstatus);
484 -
445 pids = pids->next;
446 }
447 }
@@ -500,8 +460,9 @@ static void ebpf_process_update_apps_data()
460 * @param axis the axis label
461 * @param web the group name used to attach the chart on dashaboard
462 * @param order the order number of the specified chart
463 + * @param algorithm the algorithm used to make the charts.
464 */
504 -static void ebpf_create_io_chart(char *family, char *name, char *axis, char *web, int order)
465 +static void ebpf_create_io_chart(char *family, char *name, char *axis, char *web, int order, int algorithm)
466 {
467 printf("CHART %s.%s '' 'Bytes written and read' '%s' '%s' '' line %d %d\n",
468 family,
@@ -511,8 +472,14 @@ static void ebpf_create_io_chart(char *family, char *name, char *axis, char *web
472 order,
473 update_every);
474
514 - printf("DIMENSION %s %s absolute 1 1\n", process_id_names[3], NETDATA_VFS_DIM_OUT_FILE_BYTES);
515 - printf("DIMENSION %s %s absolute 1 1\n", process_id_names[4], NETDATA_VFS_DIM_IN_FILE_BYTES);
475 + printf("DIMENSION %s %s %s 1 1\n",
476 + process_id_names[NETDATA_KEY_PUBLISH_PROCESS_READ],
477 + process_dimension_names[NETDATA_KEY_PUBLISH_PROCESS_READ],
478 + ebpf_algorithms[algorithm]);
479 + printf("DIMENSION %s %s %s 1 1\n",
480 + process_id_names[NETDATA_KEY_PUBLISH_PROCESS_WRITE],
481 + process_dimension_names[NETDATA_KEY_PUBLISH_PROCESS_WRITE],
482 + ebpf_algorithms[algorithm]);
483 }
484
485 /**
@@ -524,7 +491,8 @@ static void ebpf_create_io_chart(char *family, char *name, char *axis, char *web
491 * @param web the group name used to attach the chart on dashaboard
492 * @param order the order number of the specified chart
493 */
527 -static void ebpf_process_status_chart(char *family, char *name, char *axis, char *web, int order)
494 +static void ebpf_process_status_chart(char *family, char *name, char *axis,
495 + char *web, char *algorithm, int order)
496 {
497 printf("CHART %s.%s '' 'Process not closed' '%s' '%s' '' line %d %d ''\n",
498 family,
@@ -534,8 +502,8 @@ static void ebpf_process_status_chart(char *family, char *name, char *axis, char
502 order,
503 update_every);
504
537 - printf("DIMENSION %s '' absolute 1 1\n", status[0]);
538 - printf("DIMENSION %s '' absolute 1 1\n", status[1]);
505 + printf("DIMENSION %s '' %s 1 1\n", status[0], algorithm);
506 + printf("DIMENSION %s '' %s 1 1\n", status[1], algorithm);
507 }
508
509 /**
@@ -590,10 +558,10 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
558 2);
559
560 ebpf_create_io_chart(NETDATA_EBPF_FAMILY,
593 - NETDATA_VFS_IO_FILE_BYTES,
594 - EBPF_COMMON_DIMENSION_BYTESS,
561 + NETDATA_VFS_IO_FILE_BYTES, EBPF_COMMON_DIMENSION_BYTES,
562 NETDATA_VFS_GROUP,
596 - 21004);
563 + 21004,
564 + NETDATA_EBPF_ABSOLUTE_IDX);
565
566 if (em->mode < MODE_ENTRY) {
567 ebpf_create_chart(NETDATA_EBPF_FAMILY,
@@ -631,6 +599,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
599 NETDATA_PROCESS_STATUS_NAME,
600 EBPF_COMMON_DIMENSION_DIFFERENCE,
601 NETDATA_PROCESS_GROUP,
602 + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX],
603 21008);
604
605 if (em->mode < MODE_ENTRY) {
@@ -661,6 +630,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
630 EBPF_COMMON_DIMENSION_CALL,
631 NETDATA_APPS_FILE_GROUP,
632 20061,
633 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
634 root);
635
636 if (em->mode < MODE_ENTRY) {
@@ -669,6 +639,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
639 EBPF_COMMON_DIMENSION_CALL,
640 NETDATA_APPS_FILE_GROUP,
641 20062,
642 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
643 root);
644 }
645
@@ -677,6 +648,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
648 EBPF_COMMON_DIMENSION_CALL,
649 NETDATA_APPS_FILE_GROUP,
650 20063,
651 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
652 root);
653
654 if (em->mode < MODE_ENTRY) {
@@ -685,6 +657,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
657 EBPF_COMMON_DIMENSION_CALL,
658 NETDATA_APPS_FILE_GROUP,
659 20064,
660 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
661 root);
662 }
663
@@ -693,6 +666,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
666 EBPF_COMMON_DIMENSION_CALL,
667 NETDATA_APPS_VFS_GROUP,
668 20065,
669 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
670 root);
671
672 ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_VFS_WRITE_CALLS,
@@ -700,6 +674,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
674 EBPF_COMMON_DIMENSION_CALL,
675 NETDATA_APPS_VFS_GROUP,
676 20066,
677 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
678 apps_groups_root_target);
679
680 if (em->mode < MODE_ENTRY) {
@@ -708,6 +683,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
683 EBPF_COMMON_DIMENSION_CALL,
684 NETDATA_APPS_VFS_GROUP,
685 20067,
686 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
687 root);
688 }
689
@@ -716,6 +692,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
692 EBPF_COMMON_DIMENSION_CALL,
693 NETDATA_APPS_VFS_GROUP,
694 20068,
695 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
696 root);
697
698 if (em->mode < MODE_ENTRY) {
@@ -724,21 +701,22 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
701 EBPF_COMMON_DIMENSION_CALL,
702 NETDATA_APPS_VFS_GROUP,
703 20069,
704 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
705 root);
706 }
707
708 ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_VFS_WRITE_BYTES,
731 - "Bytes written on disk",
732 - EBPF_COMMON_DIMENSION_BYTESS,
709 + "Bytes written on disk", EBPF_COMMON_DIMENSION_BYTES,
710 NETDATA_APPS_VFS_GROUP,
711 20070,
712 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
713 root);
714
715 ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_VFS_READ_BYTES,
738 - "Bytes read from disk",
739 - EBPF_COMMON_DIMENSION_BYTESS,
716 + "Bytes read from disk", EBPF_COMMON_DIMENSION_BYTES,
717 NETDATA_APPS_VFS_GROUP,
718 20071,
719 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
720 root);
721
722 ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_TASK_PROCESS,
@@ -746,6 +724,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
724 EBPF_COMMON_DIMENSION_CALL,
725 NETDATA_APPS_PROCESS_GROUP,
726 20072,
727 + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX],
728 root);
729
730 ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_TASK_THREAD,
@@ -753,6 +732,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
732 EBPF_COMMON_DIMENSION_CALL,
733 NETDATA_APPS_PROCESS_GROUP,
734 20073,
735 + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX],
736 root);
737
738 ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_TASK_CLOSE,
@@ -760,6 +740,7 @@ static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *ro
740 EBPF_COMMON_DIMENSION_CALL,
741 NETDATA_APPS_PROCESS_GROUP,
742 20074,
743 + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX],
744 root);
745 }
746
@@ -917,20 +898,20 @@ static void ebpf_process_cleanup(void *ptr)
898
899 heartbeat_t hb;
900 heartbeat_init(&hb);
920 - uint32_t tick = 200*USEC_PER_MS;
901 + uint32_t tick = 50*USEC_PER_MS;
902 while (!finalized_threads) {
903 usec_t dt = heartbeat_next(&hb, tick);
904 UNUSED(dt);
905 }
906
907 freez(process_aggregated_data);
908 + ebpf_cleanup_publish_syscall(process_publish_aggregated);
909 freez(process_publish_aggregated);
910 freez(process_hash_values);
911
912 clean_global_memory();
913 freez(global_process_stats);
914 freez(current_apps_data);
933 - freez(prev_apps_data);
915
916 clean_apps_structures(apps_groups_root_target);
917 freez(process_data.map_fd);
@@ -965,7 +946,6 @@ static void ebpf_process_allocate_global_vectors(size_t length)
946
947 global_process_stats = callocz((size_t)pid_max, sizeof(ebpf_process_stat_t *));
948 current_apps_data = callocz((size_t)pid_max, sizeof(ebpf_process_publish_apps_t *));
968 - prev_apps_data = callocz((size_t)pid_max, sizeof(ebpf_process_publish_apps_t *));
949 }
950
951 static void change_syscalls()
@@ -1052,9 +1032,15 @@ void *ebpf_process_thread(void *ptr)
1032 goto endprocess;
1033 }
1034
1035 + int algorithms[NETDATA_KEY_PUBLISH_PROCESS_END] = {
1036 + NETDATA_EBPF_INCREMENTAL_IDX, NETDATA_EBPF_INCREMENTAL_IDX,NETDATA_EBPF_INCREMENTAL_IDX, //open, close, unlink
1037 + NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX,
1038 + NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX
1039 + };
1040 +
1041 ebpf_global_labels(
1042 process_aggregated_data, process_publish_aggregated, process_dimension_names, process_id_names,
1057 - NETDATA_MAX_MONITOR_VECTOR);
1043 + algorithms, NETDATA_MAX_MONITOR_VECTOR);
1044
1045 if (process_enabled) {
1046 ebpf_create_global_charts(em);
collectors/ebpf.plugin/ebpf_process.h
+19 -18
@@ -32,8 +32,6 @@
32 #define NETDATA_PROCESS_STATUS_NAME "process_status"
33
34 #define NETDATA_VFS_IO_FILE_BYTES "io_bytes"
35 -#define NETDATA_VFS_DIM_IN_FILE_BYTES "write"
36 -#define NETDATA_VFS_DIM_OUT_FILE_BYTES "read"
35
36 // Charts created on Apps submenu
37 #define NETDATA_SYSCALL_APPS_FILE_OPEN "file_open"
@@ -93,6 +91,25 @@ typedef enum ebpf_process_index {
91
92 } ebpf_process_index_t;
93
94 +// This enum acts as an index for publish vector.
95 +// Do not change the enum order because we use
96 +// different algorithms to make charts with incremental
97 +// values (the three initial positions) and absolute values
98 +// (the remaining charts).
99 +typedef enum netdata_publish_process {
100 + NETDATA_KEY_PUBLISH_PROCESS_OPEN,
101 + NETDATA_KEY_PUBLISH_PROCESS_CLOSE,
102 + NETDATA_KEY_PUBLISH_PROCESS_UNLINK,
103 + NETDATA_KEY_PUBLISH_PROCESS_READ,
104 + NETDATA_KEY_PUBLISH_PROCESS_WRITE,
105 + NETDATA_KEY_PUBLISH_PROCESS_EXIT,
106 + NETDATA_KEY_PUBLISH_PROCESS_RELEASE_TASK,
107 + NETDATA_KEY_PUBLISH_PROCESS_FORK,
108 + NETDATA_KEY_PUBLISH_PROCESS_CLONE,
109 +
110 + NETDATA_KEY_PUBLISH_PROCESS_END
111 +} netdata_publish_process_t;
112 +
113 typedef struct ebpf_process_publish_apps {
114 // Number of calls during the last read
115 uint64_t call_sys_open;
@@ -117,22 +134,6 @@ typedef struct ebpf_process_publish_apps {
134 // Number of bytes during the last read
135 uint64_t bytes_written;
136 uint64_t bytes_read;
120 -
121 - // Dimensions sent to chart
122 - uint64_t publish_open;
123 - uint64_t publish_closed;
124 - uint64_t publish_deleted;
125 - uint64_t publish_write_call;
126 - uint64_t publish_write_bytes;
127 - uint64_t publish_read_call;
128 - uint64_t publish_read_bytes;
129 - uint64_t publish_process;
130 - uint64_t publish_thread;
131 - uint64_t publish_task;
132 - uint64_t publish_open_error;
133 - uint64_t publish_close_error;
134 - uint64_t publish_write_error;
135 - uint64_t publish_read_error;
137 } ebpf_process_publish_apps_t;
138
139 #endif /* NETDATA_EBPF_PROCESS_H */
collectors/ebpf.plugin/ebpf_socket.c
+43 -61
@@ -23,7 +23,6 @@ static netdata_publish_syscall_t *socket_publish_aggregated = NULL;
23 static ebpf_data_t socket_data;
24
25 ebpf_socket_publish_apps_t **socket_bandwidth_curr = NULL;
26 -ebpf_socket_publish_apps_t **socket_bandwidth_prev = NULL;
26 static ebpf_bandwidth_t *bandwidth_vector = NULL;
27
28 static int socket_apps_created = 0;
@@ -86,10 +85,10 @@ static void ebpf_update_global_publish(
85 move = move->next;
86 }
87
89 - tcp->write = -((long)publish[0].nbyte);
88 + tcp->write = -(long)publish[0].nbyte;
89 tcp->read = (long)publish[1].nbyte;
90
92 - udp->write = -((long)publish[3].nbyte);
91 + udp->write = -(long)publish[3].nbyte;
92 udp->read = (long)publish[4].nbyte;
93 }
94
@@ -257,24 +256,6 @@ static void ebpf_socket_send_nv_data(netdata_vector_plot_t *ptr)
256 }
257 }
258
260 -
261 -/**
262 - * Update the publish strctures to create the dimenssions
263 - *
264 - * @param curr Last values read from memory.
265 - * @param prev Previous values read from memory.
266 - */
267 -static void ebpf_socket_update_apps_publish(ebpf_socket_publish_apps_t *curr, ebpf_socket_publish_apps_t *prev)
268 -{
269 - curr->publish_received_bytes = curr->bytes_received - prev->bytes_received;
270 - curr->publish_sent_bytes = curr->bytes_sent - prev->bytes_sent;
271 - curr->publish_tcp_sent = curr->call_tcp_sent - prev->call_tcp_sent;
272 - curr->publish_tcp_received = curr->call_tcp_received - prev->call_tcp_received;
273 - curr->publish_retransmit = curr->retransmit - prev->retransmit;
274 - curr->publish_udp_sent = curr->call_udp_sent - prev->call_udp_sent;
275 - curr->publish_udp_received = curr->call_udp_received - prev->call_udp_received;
276 -}
277 -
259 /**
260 * Send data to Netdata calling auxiliar functions.
261 *
@@ -286,10 +267,13 @@ static void ebpf_socket_send_data(ebpf_module_t *em)
267 netdata_publish_vfs_common_t common_udp;
268 ebpf_update_global_publish(socket_publish_aggregated, &common_tcp, &common_udp, socket_aggregated_data);
269
270 + // We read bytes from function arguments, but bandiwdth is given in bits,
271 + // so we need to multiply by 8 to convert for the final value.
272 write_count_chart(
273 NETDATA_TCP_FUNCTION_COUNT, NETDATA_EBPF_FAMILY, socket_publish_aggregated, 3);
274 write_io_chart(
292 - NETDATA_TCP_FUNCTION_BYTES, NETDATA_EBPF_FAMILY, socket_id_names[0], socket_id_names[1], &common_tcp);
275 + NETDATA_TCP_FUNCTION_BITS, NETDATA_EBPF_FAMILY, socket_id_names[0], common_tcp.write*8/1000,
276 + socket_id_names[1], common_tcp.read*8/1000);
277 if (em->mode < MODE_ENTRY) {
278 write_err_chart(
279 NETDATA_TCP_FUNCTION_ERROR, NETDATA_EBPF_FAMILY, socket_publish_aggregated, 2);
@@ -300,7 +284,9 @@ static void ebpf_socket_send_data(ebpf_module_t *em)
284 write_count_chart(
285 NETDATA_UDP_FUNCTION_COUNT, NETDATA_EBPF_FAMILY, &socket_publish_aggregated[NETDATA_UDP_START], 2);
286 write_io_chart(
303 - NETDATA_UDP_FUNCTION_BYTES, NETDATA_EBPF_FAMILY, socket_id_names[3], socket_id_names[4], &common_udp);
287 + NETDATA_UDP_FUNCTION_BITS, NETDATA_EBPF_FAMILY,
288 + socket_id_names[3],(long long)common_udp.write*8/100,
289 + socket_id_names[4], (long long)common_udp.read*8/1000);
290 if (em->mode < MODE_ENTRY) {
291 write_err_chart(
292 NETDATA_UDP_FUNCTION_ERROR, NETDATA_EBPF_FAMILY, &socket_publish_aggregated[NETDATA_UDP_START], 2);
@@ -351,8 +337,9 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
337 for (w = root; w; w = w->next) {
338 if (unlikely(w->exposed && w->processes)) {
339 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
354 - publish_sent_bytes));
355 - write_chart_dimension(w->name, value);
340 + bytes_sent));
341 + // We multiply by 0.008, because we read bytes, but we display bits
342 + write_chart_dimension(w->name, ((value)*8)/1000);
343 }
344 }
345 write_end_chart();
@@ -361,8 +348,9 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
348 for (w = root; w; w = w->next) {
349 if (unlikely(w->exposed && w->processes)) {
350 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
364 - publish_received_bytes));
365 - write_chart_dimension(w->name, value);
351 + bytes_received));
352 + // We multiply by 0.008, because we read bytes, but we display bits
353 + write_chart_dimension(w->name, ((value)*8)/1000);
354 }
355 }
356 write_end_chart();
@@ -371,7 +359,7 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
359 for (w = root; w; w = w->next) {
360 if (unlikely(w->exposed && w->processes)) {
361 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
374 - publish_tcp_sent));
362 + call_tcp_sent));
363 write_chart_dimension(w->name, value);
364 }
365 }
@@ -381,7 +369,7 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
369 for (w = root; w; w = w->next) {
370 if (unlikely(w->exposed && w->processes)) {
371 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
384 - publish_tcp_received));
372 + call_tcp_received));
373 write_chart_dimension(w->name, value);
374 }
375 }
@@ -391,7 +379,7 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
379 for (w = root; w; w = w->next) {
380 if (unlikely(w->exposed && w->processes)) {
381 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
394 - publish_retransmit));
382 + retransmit));
383 write_chart_dimension(w->name, value);
384 }
385 }
@@ -401,7 +389,7 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
389 for (w = root; w; w = w->next) {
390 if (unlikely(w->exposed && w->processes)) {
391 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
404 - publish_udp_sent));
392 + call_udp_sent));
393 write_chart_dimension(w->name, value);
394 }
395 }
@@ -411,7 +399,7 @@ void ebpf_socket_send_apps_data(ebpf_module_t *em, struct target *root)
399 for (w = root; w; w = w->next) {
400 if (unlikely(w->exposed && w->processes)) {
401 value = ebpf_socket_sum_values_for_pids(w->root_pid, offsetof(ebpf_socket_publish_apps_t,
414 - publish_udp_received));
402 + call_udp_received));
403 write_chart_dimension(w->name, value);
404 }
405 }
@@ -444,10 +432,8 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
432 socket_publish_aggregated,
433 3);
434
447 - ebpf_create_chart(NETDATA_EBPF_FAMILY,
448 - NETDATA_TCP_FUNCTION_BYTES,
449 - "TCP bandwidth",
450 - EBPF_COMMON_DIMENSION_BYTESS,
435 + ebpf_create_chart(NETDATA_EBPF_FAMILY, NETDATA_TCP_FUNCTION_BITS,
436 + "TCP bandwidth", EBPF_COMMON_DIMENSION_BITS,
437 NETDATA_SOCKET_GROUP,
438 21071,
439 ebpf_create_global_dimension,
@@ -486,10 +472,8 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
472 &socket_publish_aggregated[NETDATA_UDP_START],
473 2);
474
489 - ebpf_create_chart(NETDATA_EBPF_FAMILY,
490 - NETDATA_UDP_FUNCTION_BYTES,
491 - "UDP bandwidth",
492 - EBPF_COMMON_DIMENSION_BYTESS,
475 + ebpf_create_chart(NETDATA_EBPF_FAMILY, NETDATA_UDP_FUNCTION_BITS,
476 + "UDP bandwidth", EBPF_COMMON_DIMENSION_BITS,
477 NETDATA_SOCKET_GROUP,
478 21075,
479 ebpf_create_global_dimension,
@@ -520,17 +504,17 @@ void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
504 {
505 UNUSED(em);
506 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_SENT,
523 - "Bytes sent",
524 - EBPF_COMMON_DIMENSION_BYTESS,
507 + "Bytes sent", EBPF_COMMON_DIMENSION_BITS,
508 NETDATA_APPS_NET_GROUP,
509 20080,
510 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
511 root);
512
513 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_RECV,
530 - "bytes received",
531 - EBPF_COMMON_DIMENSION_BYTESS,
514 + "bytes received", EBPF_COMMON_DIMENSION_BITS,
515 NETDATA_APPS_NET_GROUP,
516 20081,
517 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
518 root);
519
520 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_TCP_SEND_CALLS,
@@ -538,6 +522,7 @@ void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
522 EBPF_COMMON_DIMENSION_CALL,
523 NETDATA_APPS_NET_GROUP,
524 20082,
525 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
526 root);
527
528 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_TCP_RECV_CALLS,
@@ -545,6 +530,7 @@ void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
530 EBPF_COMMON_DIMENSION_CALL,
531 NETDATA_APPS_NET_GROUP,
532 20083,
533 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
534 root);
535
536 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_TCP_RETRANSMIT,
@@ -552,6 +538,7 @@ void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
538 EBPF_COMMON_DIMENSION_CALL,
539 NETDATA_APPS_NET_GROUP,
540 20084,
541 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
542 root);
543
544 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_UDP_SEND_CALLS,
@@ -559,6 +546,7 @@ void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
546 EBPF_COMMON_DIMENSION_CALL,
547 NETDATA_APPS_NET_GROUP,
548 20085,
549 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
550 root);
551
552 ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_UDP_RECV_CALLS,
@@ -566,6 +554,7 @@ void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
554 EBPF_COMMON_DIMENSION_CALL,
555 NETDATA_APPS_NET_GROUP,
556 20086,
557 + ebpf_algorithms[NETDATA_EBPF_INCREMENTAL_IDX],
558 root);
559
560 socket_apps_created = 1;
@@ -658,8 +647,7 @@ static void ebpf_socket_create_nv_charts(netdata_vector_plot_t *ptr)
647
648 if (ptr == (netdata_vector_plot_t *)&outbound_vectors) {
649 ebpf_socket_create_nv_chart(NETDATA_NV_OUTBOUND_BYTES,
661 - "Outbound connections (bytes).",
662 - EBPF_COMMON_DIMENSION_BYTESS,
650 + "Outbound connections (bytes).", EBPF_COMMON_DIMENSION_BYTES,
651 NETDATA_NETWORK_CONNECTIONS_GROUP,
652 21080,
653 ptr);
@@ -679,8 +667,7 @@ static void ebpf_socket_create_nv_charts(netdata_vector_plot_t *ptr)
667 ptr);
668 } else {
669 ebpf_socket_create_nv_chart(NETDATA_NV_INBOUND_BYTES,
682 - "Inbound connections (bytes)",
683 - EBPF_COMMON_DIMENSION_BYTESS,
670 + "Inbound connections (bytes)", EBPF_COMMON_DIMENSION_BYTES,
671 NETDATA_NETWORK_CONNECTIONS_GROUP,
672 21084,
673 ptr);
@@ -1511,15 +1498,9 @@ static void read_hash_global_tables()
1498 void ebpf_socket_fill_publish_apps(uint32_t current_pid, ebpf_bandwidth_t *eb)
1499 {
1500 ebpf_socket_publish_apps_t *curr = socket_bandwidth_curr[current_pid];
1514 - ebpf_socket_publish_apps_t *prev = socket_bandwidth_prev[current_pid];
1501 if (!curr) {
1516 - ebpf_socket_publish_apps_t *ptr = callocz(2, sizeof(ebpf_socket_publish_apps_t));
1517 - curr = &ptr[0];
1502 + curr = callocz(1, sizeof(ebpf_socket_publish_apps_t));
1503 socket_bandwidth_curr[current_pid] = curr;
1519 - prev = &ptr[1];
1520 - socket_bandwidth_prev[current_pid] = prev;
1521 - } else {
1522 - memcpy(prev, curr, sizeof(ebpf_socket_publish_apps_t));
1504 }
1505
1506 curr->bytes_sent = eb->bytes_sent;
@@ -1529,8 +1510,6 @@ void ebpf_socket_fill_publish_apps(uint32_t current_pid, ebpf_bandwidth_t *eb)
1510 curr->retransmit = eb->retransmit;
1511 curr->call_udp_sent = eb->call_udp_sent;
1512 curr->call_udp_received = eb->call_udp_received;
1532 -
1533 - ebpf_socket_update_apps_publish(curr, prev);
1513 }
1514
1515 /**
@@ -1778,19 +1757,19 @@ static void ebpf_socket_cleanup(void *ptr)
1757
1758 heartbeat_t hb;
1759 heartbeat_init(&hb);
1781 - uint32_t tick = 200*USEC_PER_MS;
1760 + uint32_t tick = 2*USEC_PER_MS;
1761 while (!read_thread_closed) {
1762 usec_t dt = heartbeat_next(&hb, tick);
1763 UNUSED(dt);
1764 }
1765
1766 freez(socket_aggregated_data);
1767 + ebpf_cleanup_publish_syscall(socket_publish_aggregated);
1768 freez(socket_publish_aggregated);
1769 freez(socket_hash_values);
1770
1771 clean_thread_structures();
1772 freez(socket_bandwidth_curr);
1793 - freez(socket_bandwidth_prev);
1773 freez(bandwidth_vector);
1774
1775 freez(socket_values);
@@ -1843,7 +1822,6 @@ static void ebpf_socket_allocate_global_vectors(size_t length)
1822 socket_hash_values = callocz(ebpf_nprocs, sizeof(netdata_idx_t));
1823
1824 socket_bandwidth_curr = callocz((size_t)pid_max, sizeof(ebpf_socket_publish_apps_t *));
1846 - socket_bandwidth_prev = callocz((size_t)pid_max, sizeof(ebpf_socket_publish_apps_t *));
1825 bandwidth_vector = callocz((size_t)ebpf_nprocs, sizeof(ebpf_bandwidth_t));
1826
1827 socket_values = callocz((size_t)ebpf_nprocs, sizeof(netdata_socket_t));
@@ -1921,9 +1899,13 @@ void *ebpf_socket_thread(void *ptr)
1899 goto endsocket;
1900 }
1901
1902 + int algorithms[NETDATA_MAX_SOCKET_VECTOR] = {
1903 + NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX,
1904 + NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX
1905 + };
1906 ebpf_global_labels(
1907 socket_aggregated_data, socket_publish_aggregated, socket_dimension_names, socket_id_names,
1926 - NETDATA_MAX_SOCKET_VECTOR);
1908 + algorithms, NETDATA_MAX_SOCKET_VECTOR);
1909
1910 ebpf_create_global_charts(em);
1911
collectors/ebpf.plugin/ebpf_socket.h
+4 -5
@@ -46,16 +46,16 @@ typedef enum ebpf_socket_idx {
46
47 // Global chart name
48 #define NETDATA_TCP_FUNCTION_COUNT "tcp_functions"
49 -#define NETDATA_TCP_FUNCTION_BYTES "tcp_bandwidth"
49 +#define NETDATA_TCP_FUNCTION_BITS "total_tcp_bandwidth"
50 #define NETDATA_TCP_FUNCTION_ERROR "tcp_error"
51 #define NETDATA_TCP_RETRANSMIT "tcp_retransmit"
52 #define NETDATA_UDP_FUNCTION_COUNT "udp_functions"
53 -#define NETDATA_UDP_FUNCTION_BYTES "udp_bandwidth"
53 +#define NETDATA_UDP_FUNCTION_BITS "total_udp_bandwidth"
54 #define NETDATA_UDP_FUNCTION_ERROR "udp_error"
55
56 // Charts created on Apps submenu
57 -#define NETDATA_NET_APPS_BANDWIDTH_SENT "bandwidth_sent"
58 -#define NETDATA_NET_APPS_BANDWIDTH_RECV "bandwidth_recv"
57 +#define NETDATA_NET_APPS_BANDWIDTH_SENT "total_bandwidth_sent"
58 +#define NETDATA_NET_APPS_BANDWIDTH_RECV "total_bandwidth_recv"
59 #define NETDATA_NET_APPS_BANDWIDTH_TCP_SEND_CALLS "bandwidth_tcp_send"
60 #define NETDATA_NET_APPS_BANDWIDTH_TCP_RECV_CALLS "bandwidth_tcp_recv"
61 #define NETDATA_NET_APPS_BANDWIDTH_TCP_RETRANSMIT "bandwidth_tcp_retransmit"
@@ -271,6 +271,5 @@ extern ebpf_network_viewer_port_list_t *listen_ports;
271 extern void update_listen_table(uint16_t value, uint8_t proto);
272
273 extern ebpf_socket_publish_apps_t **socket_bandwidth_curr;
274 -extern ebpf_socket_publish_apps_t **socket_bandwidth_prev;
274
275 #endif
packaging/ebpf.checksums
+3 -3
@@ -1,3 +1,3 @@
1 -bcc2e38754f277e84aefdb2760d7de2b32611576718234e1cecdb70a87e93497 netdata-kernel-collector-glibc-v0.5.4.tar.xz
2 -912675155f438c9fdccc1e91c1423fa4bb914a9c7e2d7b843f551e053f4374eb netdata-kernel-collector-musl-v0.5.4.tar.xz
3 -dd0f63895305c38669b512f9e95a75057340f04ea999c3ea3540cb18a893dc52 netdata-kernel-collector-static-v0.5.4.tar.xz
1 +d9c1c81fe3a8b9af7fc1174a28c16ddb24e2f3ff79e6beb1b2eb184bf0d2e8c0 netdata-kernel-collector-glibc-v0.5.5.tar.xz
2 +0e1dd5e12a58dda53576b2dab963cd26fa26fe2084d84c51becb9238d1055fc1 netdata-kernel-collector-musl-v0.5.5.tar.xz
3 +d6d65e5f40a83880aa7dd740829a7ffe6a0805637e1616805aebdff088a3fcb0 netdata-kernel-collector-static-v0.5.5.tar.xz
packaging/ebpf.version
+1 -1
@@ -1 +1 @@
1 -v0.5.4
1 +v0.5.5