diff options
Diffstat (limited to 'src/collectors/ebpf.plugin/ebpf_socket.c')
-rw-r--r-- | src/collectors/ebpf.plugin/ebpf_socket.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf_socket.c b/src/collectors/ebpf.plugin/ebpf_socket.c index 5b87a3256..f0d376f43 100644 --- a/src/collectors/ebpf.plugin/ebpf_socket.c +++ b/src/collectors/ebpf.plugin/ebpf_socket.c @@ -77,11 +77,7 @@ netdata_socket_t *socket_values; ebpf_network_viewer_port_list_t *listen_ports = NULL; ebpf_addresses_t tcp_v6_connect_address = {.function = "tcp_v6_connect", .hash = 0, .addr = 0, .type = 0}; -struct config socket_config = { .first_section = NULL, - .last_section = NULL, - .mutex = NETDATA_MUTEX_INITIALIZER, - .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare }, - .rwlock = AVL_LOCK_INITIALIZER } }; +struct config socket_config = APPCONFIG_INITIALIZER; netdata_ebpf_targets_t socket_targets[] = { {.name = "inet_csk_accept", .mode = EBPF_LOAD_PROBE}, {.name = "tcp_retransmit_skb", .mode = EBPF_LOAD_PROBE}, @@ -1815,9 +1811,6 @@ void ebpf_socket_resume_apps_data() */ void *ebpf_read_socket_thread(void *ptr) { - heartbeat_t hb; - heartbeat_init(&hb); - ebpf_module_t *em = (ebpf_module_t *)ptr; ebpf_update_array_vectors(em); @@ -1830,9 +1823,10 @@ void *ebpf_read_socket_thread(void *ptr) uint32_t running_time = 0; uint32_t lifetime = em->lifetime; - usec_t period = update_every * USEC_PER_SEC; + heartbeat_t hb; + heartbeat_init(&hb, update_every * USEC_PER_SEC); while (!ebpf_plugin_stop() && running_time < lifetime) { - (void)heartbeat_next(&hb, period); + heartbeat_next(&hb); if (ebpf_plugin_stop() || ++counter != update_every) continue; @@ -2612,9 +2606,6 @@ static void ebpf_socket_send_cgroup_data(int update_every) */ static void socket_collector(ebpf_module_t *em) { - heartbeat_t hb; - heartbeat_init(&hb); - int cgroups = em->cgroup_charts; if (cgroups) ebpf_socket_update_cgroup_algorithm(); @@ -2627,8 +2618,10 @@ static void socket_collector(ebpf_module_t *em) uint32_t lifetime = em->lifetime; netdata_idx_t *stats = em->hash_table_stats; memset(stats, 0, sizeof(em->hash_table_stats)); + heartbeat_t hb; + heartbeat_init(&hb, USEC_PER_SEC); while (!ebpf_plugin_stop() && running_time < lifetime) { - (void)heartbeat_next(&hb, USEC_PER_SEC); + heartbeat_next(&hb); if (ebpf_plugin_stop() || ++counter != update_every) continue; @@ -2708,7 +2701,7 @@ static void ebpf_socket_initialize_global_vectors() * @param hash the calculated hash for the dimension name. * @param name the dimension name. */ -static void ebpf_link_dimension_name(char *port, uint32_t hash, char *value) +static void ebpf_link_dimension_name(const char *port, uint32_t hash, const char *value) { int test = str2i(port); if (test < NETDATA_MINIMUM_PORT_VALUE || test > NETDATA_MAXIMUM_PORT_VALUE){ @@ -2753,15 +2746,15 @@ static void ebpf_link_dimension_name(char *port, uint32_t hash, char *value) * * @param cfg the configuration structure */ + +static bool config_service_value_cb(void *data __maybe_unused, const char *name, const char *value) { + ebpf_link_dimension_name(name, simple_hash(name), value); + return true; +} + void ebpf_parse_service_name_section(struct config *cfg) { - struct section *co = appconfig_get_section(cfg, EBPF_SERVICE_NAME_SECTION); - if (co) { - struct config_option *cv; - for (cv = co->values; cv ; cv = cv->next) { - ebpf_link_dimension_name(cv->name, cv->hash, cv->value); - } - } + appconfig_foreach_value_in_section(cfg, EBPF_SERVICE_NAME_SECTION, config_service_value_cb, NULL); // Always associated the default port to Netdata ebpf_network_viewer_dim_name_t *names = network_viewer_opt.names; |