diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2022-07-18 12:09:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-18 12:09:02 +0000 |
commit | 7f7225dfaa81a928df5e46db5274d18875c880cf (patch) | |
tree | 3b00c4533b25cdea846979b4b4ce981f3325d4e2 /collectors/ebpf.plugin/ebpf_dcstat.c | |
parent | 9dc631e50ab9d63fad2fbe724aaaf2ffd7c657d3 (diff) |
Fix chart update ebpf.plugin (#13351)
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_dcstat.c')
-rw-r--r-- | collectors/ebpf.plugin/ebpf_dcstat.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/collectors/ebpf.plugin/ebpf_dcstat.c b/collectors/ebpf.plugin/ebpf_dcstat.c index 4344b98875..1f4dc4a2e9 100644 --- a/collectors/ebpf.plugin/ebpf_dcstat.c +++ b/collectors/ebpf.plugin/ebpf_dcstat.c @@ -868,7 +868,7 @@ static int ebpf_send_systemd_dc_charts() for (ect = ebpf_cgroup_pids; ect ; ect = ect->next) { if (unlikely(ect->systemd) && unlikely(ect->updated)) { write_chart_dimension(ect->name, (long long) ect->publish_dc.ratio); - } else + } else if (unlikely(ect->systemd)) ret = 0; } write_end_chart(); @@ -1008,32 +1008,30 @@ static void dcstat_collector(ebpf_module_t *em) int apps = em->apps_charts; int cgroups = em->cgroup_charts; int update_every = em->update_every; - int counter = update_every - 1; + heartbeat_t hb; + heartbeat_init(&hb); + usec_t step = update_every * USEC_PER_SEC; while (!close_ebpf_plugin) { - pthread_mutex_lock(&collect_data_mutex); - pthread_cond_wait(&collect_data_cond_var, &collect_data_mutex); + (void)heartbeat_next(&hb, step); - if (++counter == update_every) { - counter = 0; - if (apps) - read_apps_table(); - - if (cgroups) - ebpf_update_dc_cgroup(); + pthread_mutex_lock(&collect_data_mutex); + if (apps) + read_apps_table(); - pthread_mutex_lock(&lock); + if (cgroups) + ebpf_update_dc_cgroup(); - dcstat_send_global(&publish); + pthread_mutex_lock(&lock); - if (apps) - ebpf_dcache_send_apps_data(apps_groups_root_target); + dcstat_send_global(&publish); - if (cgroups) - ebpf_dc_send_cgroup_data(update_every); + if (apps) + ebpf_dcache_send_apps_data(apps_groups_root_target); - pthread_mutex_unlock(&lock); - } + if (cgroups) + ebpf_dc_send_cgroup_data(update_every); + pthread_mutex_unlock(&lock); pthread_mutex_unlock(&collect_data_mutex); } } |