|
@@ -160,7 +160,7 @@ static int ebpf_send_systemd_oomkill_charts()
|
|
if (unlikely(ect->systemd) && unlikely(ect->updated)) {
|
|
if (unlikely(ect->systemd) && unlikely(ect->updated)) {
|
|
write_chart_dimension(ect->name, (long long) ect->oomkill);
|
|
write_chart_dimension(ect->name, (long long) ect->oomkill);
|
|
ect->oomkill = 0;
|
|
ect->oomkill = 0;
|
|
- } else
|
|
|
|
|
|
+ } else if (unlikely(ect->systemd))
|
|
ret = 0;
|
|
ret = 0;
|
|
}
|
|
}
|
|
write_end_chart();
|
|
write_end_chart();
|
|
@@ -313,34 +313,32 @@ static void oomkill_collector(ebpf_module_t *em)
|
|
{
|
|
{
|
|
int cgroups = em->cgroup_charts;
|
|
int cgroups = em->cgroup_charts;
|
|
int update_every = em->update_every;
|
|
int update_every = em->update_every;
|
|
- int counter = update_every - 1;
|
|
|
|
int32_t keys[NETDATA_OOMKILL_MAX_ENTRIES];
|
|
int32_t keys[NETDATA_OOMKILL_MAX_ENTRIES];
|
|
memset(keys, 0, sizeof(keys));
|
|
memset(keys, 0, sizeof(keys));
|
|
|
|
|
|
// loop and read until ebpf plugin is closed.
|
|
// loop and read until ebpf plugin is closed.
|
|
|
|
+ heartbeat_t hb;
|
|
|
|
+ heartbeat_init(&hb);
|
|
|
|
+ usec_t step = update_every * USEC_PER_SEC;
|
|
while (!close_ebpf_plugin) {
|
|
while (!close_ebpf_plugin) {
|
|
- pthread_mutex_lock(&collect_data_mutex);
|
|
|
|
- pthread_cond_wait(&collect_data_cond_var, &collect_data_mutex);
|
|
|
|
-
|
|
|
|
- if (++counter == update_every) {
|
|
|
|
- counter = 0;
|
|
|
|
- pthread_mutex_lock(&lock);
|
|
|
|
|
|
+ (void)heartbeat_next(&hb, step);
|
|
|
|
|
|
- uint32_t count = oomkill_read_data(keys);
|
|
|
|
- if (cgroups && count)
|
|
|
|
- ebpf_update_oomkill_cgroup(keys, count);
|
|
|
|
|
|
+ pthread_mutex_lock(&collect_data_mutex);
|
|
|
|
+ pthread_mutex_lock(&lock);
|
|
|
|
|
|
- // write everything from the ebpf map.
|
|
|
|
- if (cgroups)
|
|
|
|
- ebpf_oomkill_send_cgroup_data(update_every);
|
|
|
|
|
|
+ uint32_t count = oomkill_read_data(keys);
|
|
|
|
+ if (cgroups && count)
|
|
|
|
+ ebpf_update_oomkill_cgroup(keys, count);
|
|
|
|
|
|
- write_begin_chart(NETDATA_APPS_FAMILY, NETDATA_OOMKILL_CHART);
|
|
|
|
- oomkill_write_data(keys, count);
|
|
|
|
- write_end_chart();
|
|
|
|
|
|
+ // write everything from the ebpf map.
|
|
|
|
+ if (cgroups)
|
|
|
|
+ ebpf_oomkill_send_cgroup_data(update_every);
|
|
|
|
|
|
- pthread_mutex_unlock(&lock);
|
|
|
|
- }
|
|
|
|
|
|
+ write_begin_chart(NETDATA_APPS_FAMILY, NETDATA_OOMKILL_CHART);
|
|
|
|
+ oomkill_write_data(keys, count);
|
|
|
|
+ write_end_chart();
|
|
|
|
|
|
|
|
+ pthread_mutex_unlock(&lock);
|
|
pthread_mutex_unlock(&collect_data_mutex);
|
|
pthread_mutex_unlock(&collect_data_mutex);
|
|
}
|
|
}
|
|
}
|
|
}
|