summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf_dcstat.c
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2021-06-10 12:33:14 +0000
committerGitHub <noreply@github.com>2021-06-10 12:33:14 +0000
commit7f1f23d5fbfcbd46687ecd29419493ca1230821e (patch)
treee24c0d5c41ca0a098a0859bceed1ce138eb46f7a /collectors/ebpf.plugin/ebpf_dcstat.c
parent86c9ada59d5d7e1876d36aa1ffea13f1da90b10d (diff)
Ebpf arrays (#11230)
Update our code to read the modified table.
Diffstat (limited to 'collectors/ebpf.plugin/ebpf_dcstat.c')
-rw-r--r--collectors/ebpf.plugin/ebpf_dcstat.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/collectors/ebpf.plugin/ebpf_dcstat.c b/collectors/ebpf.plugin/ebpf_dcstat.c
index 4fcfc16741..1f58d11337 100644
--- a/collectors/ebpf.plugin/ebpf_dcstat.c
+++ b/collectors/ebpf.plugin/ebpf_dcstat.c
@@ -17,6 +17,7 @@ static struct bpf_object *objects = NULL;
static int *map_fd = NULL;
static netdata_idx_t dcstat_hash_values[NETDATA_DCSTAT_IDX_END];
+static netdata_idx_t *dcstat_values = NULL;
static int read_thread_closed = 1;
@@ -117,6 +118,7 @@ static void ebpf_dcstat_cleanup(void *ptr)
}
freez(dcstat_vector);
+ freez(dcstat_values);
ebpf_cleanup_publish_syscall(dcstat_counter_publish_aggregated);
@@ -284,12 +286,18 @@ static void read_global_table()
{
uint32_t idx;
netdata_idx_t *val = dcstat_hash_values;
- netdata_idx_t stored;
+ netdata_idx_t *stored = dcstat_values;
int fd = map_fd[NETDATA_DCSTAT_GLOBAL_STATS];
for (idx = NETDATA_KEY_DC_REFERENCE; idx < NETDATA_DIRECTORY_CACHE_END; idx++) {
- if (!bpf_map_lookup_elem(fd, &idx, &stored)) {
- val[idx] = stored;
+ if (!bpf_map_lookup_elem(fd, &idx, stored)) {
+ int i;
+ int end = ebpf_nprocs;
+ netdata_idx_t total = 0;
+ for (i = 0; i < end; i++)
+ total += stored[i];
+
+ val[idx] = total;
}
}
}
@@ -539,6 +547,7 @@ static void ebpf_dcstat_allocate_global_vectors(size_t length)
{
dcstat_pid = callocz((size_t)pid_max, sizeof(netdata_publish_dcstat_t *));
dcstat_vector = callocz((size_t)ebpf_nprocs, sizeof(netdata_dcstat_pid_t));
+ dcstat_values = callocz((size_t)ebpf_nprocs, sizeof(netdata_idx_t));
memset(dcstat_counter_aggregated_data, 0, length*sizeof(netdata_syscall_stat_t));
memset(dcstat_counter_publish_aggregated, 0, length*sizeof(netdata_publish_syscall_t));