summaryrefslogtreecommitdiffstats
path: root/src/collectors/ebpf.plugin/ebpf_dcstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/collectors/ebpf.plugin/ebpf_dcstat.c')
-rw-r--r--src/collectors/ebpf.plugin/ebpf_dcstat.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf_dcstat.c b/src/collectors/ebpf.plugin/ebpf_dcstat.c
index e6053cb4a..e84517686 100644
--- a/src/collectors/ebpf.plugin/ebpf_dcstat.c
+++ b/src/collectors/ebpf.plugin/ebpf_dcstat.c
@@ -12,11 +12,7 @@ netdata_dcstat_pid_t *dcstat_vector = NULL;
static netdata_idx_t dcstat_hash_values[NETDATA_DCSTAT_IDX_END];
static netdata_idx_t *dcstat_values = NULL;
-struct config dcstat_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 dcstat_config = APPCONFIG_INITIALIZER;
ebpf_local_maps_t dcstat_maps[] = {{.name = "dcstat_global", .internal_input = NETDATA_DIRECTORY_CACHE_END,
.user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,
@@ -542,9 +538,8 @@ static void ebpf_dcstat_apps_accumulator(netdata_dcstat_pid_t *out, int maps_per
* Read the apps table and store data inside the structure.
*
* @param maps_per_core do I need to read all cores?
- * @param max_period limit of iterations without updates before remove data from hash table
*/
-static void ebpf_read_dc_apps_table(int maps_per_core, uint32_t max_period)
+static void ebpf_read_dc_apps_table(int maps_per_core)
{
netdata_dcstat_pid_t *cv = dcstat_vector;
int fd = dcstat_maps[NETDATA_DCSTAT_PID_STATS].map_fd;
@@ -644,9 +639,6 @@ void ebpf_dc_resume_apps_data()
*/
void *ebpf_read_dcstat_thread(void *ptr)
{
- heartbeat_t hb;
- heartbeat_init(&hb);
-
ebpf_module_t *em = (ebpf_module_t *)ptr;
int maps_per_core = em->maps_per_core;
@@ -659,16 +651,16 @@ void *ebpf_read_dcstat_thread(void *ptr)
uint32_t lifetime = em->lifetime;
uint32_t running_time = 0;
- usec_t period = update_every * USEC_PER_SEC;
- uint32_t max_period = EBPF_CLEANUP_FACTOR;
pids_fd[EBPF_PIDS_DCSTAT_IDX] = dcstat_maps[NETDATA_DCSTAT_PID_STATS].map_fd;
+ heartbeat_t hb;
+ heartbeat_init(&hb, update_every * USEC_PER_SEC);
while (!ebpf_plugin_stop() && running_time < lifetime) {
- (void)heartbeat_next(&hb, period);
+ (void)heartbeat_next(&hb);
if (ebpf_plugin_stop() || ++counter != update_every)
continue;
pthread_mutex_lock(&collect_data_mutex);
- ebpf_read_dc_apps_table(maps_per_core, max_period);
+ ebpf_read_dc_apps_table(maps_per_core);
ebpf_dc_resume_apps_data();
pthread_mutex_unlock(&collect_data_mutex);
@@ -1271,7 +1263,7 @@ static void dcstat_collector(ebpf_module_t *em)
int cgroups = em->cgroup_charts;
int update_every = em->update_every;
heartbeat_t hb;
- heartbeat_init(&hb);
+ heartbeat_init(&hb, USEC_PER_SEC);
int counter = update_every - 1;
int maps_per_core = em->maps_per_core;
uint32_t running_time = 0;
@@ -1279,7 +1271,7 @@ static void dcstat_collector(ebpf_module_t *em)
netdata_idx_t *stats = em->hash_table_stats;
memset(stats, 0, sizeof(em->hash_table_stats));
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;