summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2020-04-20 20:16:06 +0000
committerGitHub <noreply@github.com>2020-04-20 20:16:06 +0000
commitc226f1b42ab935870a32ea6408699e7af1768a27 (patch)
tree098b791464a00d0b7c600c88344d3f7eebadf250 /collectors
parentb30a70a092079d30e03a97e666d60ee63232f5b3 (diff)
Ebpf index size (#8743)
Adjusts the index size inside eBPF collector to avoid reset on indexes.
Diffstat (limited to 'collectors')
-rw-r--r--collectors/ebpf_process.plugin/ebpf_process.c50
-rw-r--r--collectors/ebpf_process.plugin/ebpf_process.h44
2 files changed, 69 insertions, 25 deletions
diff --git a/collectors/ebpf_process.plugin/ebpf_process.c b/collectors/ebpf_process.plugin/ebpf_process.c
index afa24e1294..8691b71e16 100644
--- a/collectors/ebpf_process.plugin/ebpf_process.c
+++ b/collectors/ebpf_process.plugin/ebpf_process.c
@@ -73,7 +73,7 @@ struct config collector_config;
static int mykernel = 0;
static int nprocs;
static int isrh;
-uint32_t *hash_values;
+netdata_idx_t *hash_values;
pthread_mutex_t lock;
@@ -511,15 +511,15 @@ void *process_publisher(void *ptr)
}
static void move_from_kernel2user_global() {
- uint32_t idx;
- uint32_t res[NETDATA_GLOBAL_VECTOR];
+ uint64_t idx;
+ netdata_idx_t res[NETDATA_GLOBAL_VECTOR];
- uint32_t *val = hash_values;
+ netdata_idx_t *val = hash_values;
for (idx = 0; idx < NETDATA_GLOBAL_VECTOR; idx++) {
if(!bpf_map_lookup_elem(map_fd[1], &idx, val)) {
- uint32_t total = 0;
+ uint64_t total = 0;
int i;
- int end = (mykernel < 265984)?1:nprocs;
+ int end = (mykernel < NETDATA_KERNEL_V4_15)?1:nprocs;
for (i = 0; i < end; i++)
total += val[i];
@@ -529,26 +529,26 @@ static void move_from_kernel2user_global() {
}
}
- aggregated_data[0].call = res[0]; //open
- aggregated_data[1].call = res[14]; //close
- aggregated_data[2].call = res[8]; //unlink
- aggregated_data[3].call = res[5] + res[21]; //read + readv
- aggregated_data[4].call = res[2] + res[18]; //write + writev
- aggregated_data[5].call = res[10]; //exit
- aggregated_data[6].call = res[11]; //release
- aggregated_data[7].call = res[12]; //fork
- aggregated_data[8].call = res[16]; //thread
+ aggregated_data[0].call = res[NETDATA_KEY_CALLS_DO_SYS_OPEN];
+ aggregated_data[1].call = res[NETDATA_KEY_CALLS_CLOSE_FD];
+ aggregated_data[2].call = res[NETDATA_KEY_CALLS_VFS_UNLINK];
+ aggregated_data[3].call = res[NETDATA_KEY_CALLS_VFS_READ] + res[NETDATA_KEY_CALLS_VFS_READV];
+ aggregated_data[4].call = res[NETDATA_KEY_CALLS_VFS_WRITE] + res[NETDATA_KEY_CALLS_VFS_WRITEV];
+ aggregated_data[5].call = res[NETDATA_KEY_CALLS_DO_EXIT];
+ aggregated_data[6].call = res[NETDATA_KEY_CALLS_RELEASE_TASK];
+ aggregated_data[7].call = res[NETDATA_KEY_CALLS_DO_FORK];
+ aggregated_data[8].call = res[NETDATA_KEY_CALLS_SYS_CLONE];
- aggregated_data[0].ecall = res[1]; //open
- aggregated_data[1].ecall = res[15]; //close
- aggregated_data[2].ecall = res[9]; //unlink
- aggregated_data[3].ecall = res[6] + res[22]; //read + readv
- aggregated_data[4].ecall = res[3] + res[19]; //write + writev
- aggregated_data[7].ecall = res[13]; //fork
- aggregated_data[8].ecall = res[17]; //thread
+ aggregated_data[0].ecall = res[NETDATA_KEY_ERROR_DO_SYS_OPEN];
+ aggregated_data[1].ecall = res[NETDATA_KEY_ERROR_CLOSE_FD];
+ aggregated_data[2].ecall = res[NETDATA_KEY_ERROR_VFS_UNLINK];
+ aggregated_data[3].ecall = res[NETDATA_KEY_ERROR_VFS_READ] + res[NETDATA_KEY_ERROR_VFS_READV];
+ aggregated_data[4].ecall = res[NETDATA_KEY_ERROR_VFS_WRITE] + res[NETDATA_KEY_ERROR_VFS_WRITEV];
+ aggregated_data[7].ecall = res[NETDATA_KEY_ERROR_DO_FORK];
+ aggregated_data[8].ecall = res[NETDATA_KEY_ERROR_SYS_CLONE];
- aggregated_data[2].bytes = (uint64_t)res[4] + (uint64_t)res[20]; //write + writev
- aggregated_data[3].bytes = (uint64_t)res[7] + (uint64_t)res[23];//read + readv
+ aggregated_data[2].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITE] + (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITEV];
+ aggregated_data[3].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_READ] + (uint64_t)res[NETDATA_KEY_BYTES_VFS_READV];
}
static void move_from_kernel2user()
@@ -638,7 +638,7 @@ int allocate_global_vectors() {
return -1;
}
- hash_values = callocz(nprocs, sizeof(uint32_t));
+ hash_values = callocz(nprocs, sizeof(netdata_idx_t));
if(!hash_values) {
return -1;
}
diff --git a/collectors/ebpf_process.plugin/ebpf_process.h b/collectors/ebpf_process.plugin/ebpf_process.h
index a0f6ddb1c3..9813c88576 100644
--- a/collectors/ebpf_process.plugin/ebpf_process.h
+++ b/collectors/ebpf_process.plugin/ebpf_process.h
@@ -48,6 +48,8 @@ typedef struct netdata_syscall_stat {
struct netdata_syscall_stat *next; //Link list
}netdata_syscall_stat_t;
+typedef uint64_t netdata_idx_t;
+
typedef struct netdata_publish_syscall {
char *dimension;
char *name;
@@ -76,6 +78,7 @@ typedef struct netdata_error_report {
int err;
}netdata_error_report_t;
+//Chart defintions
# define NETDATA_EBPF_FAMILY "ebpf"
# define NETDATA_FILE_GROUP "File"
# define NETDATA_VFS_GROUP "VFS"
@@ -96,10 +99,51 @@ typedef struct netdata_error_report {
# define NETDATA_VFS_DIM_IN_FILE_BYTES "write"
# define NETDATA_VFS_DIM_OUT_FILE_BYTES "read"
+//Log file
# define NETDATA_DEVELOPER_LOG_FILE "developer.log"
+//Maximum number of processors monitored on perf events
# define NETDATA_MAX_PROCESSOR 512
+//Kernel versions calculated with the formula:
+// R = MAJOR*65536 + MINOR*256 + PATCH
# define NETDATA_KERNEL_V5_3 328448
+# define NETDATA_KERNEL_V4_15 265984
+
+//Index from kernel
+# define NETDATA_KEY_CALLS_DO_SYS_OPEN 0
+# define NETDATA_KEY_ERROR_DO_SYS_OPEN 1
+
+# define NETDATA_KEY_CALLS_VFS_WRITE 2
+# define NETDATA_KEY_ERROR_VFS_WRITE 3
+# define NETDATA_KEY_BYTES_VFS_WRITE 4
+
+# define NETDATA_KEY_CALLS_VFS_READ 5
+# define NETDATA_KEY_ERROR_VFS_READ 6
+# define NETDATA_KEY_BYTES_VFS_READ 7
+
+# define NETDATA_KEY_CALLS_VFS_UNLINK 8
+# define NETDATA_KEY_ERROR_VFS_UNLINK 9
+
+# define NETDATA_KEY_CALLS_DO_EXIT 10
+
+# define NETDATA_KEY_CALLS_RELEASE_TASK 11
+
+# define NETDATA_KEY_CALLS_DO_FORK 12
+# define NETDATA_KEY_ERROR_DO_FORK 13
+
+# define NETDATA_KEY_CALLS_CLOSE_FD 14
+# define NETDATA_KEY_ERROR_CLOSE_FD 15
+
+# define NETDATA_KEY_CALLS_SYS_CLONE 16
+# define NETDATA_KEY_ERROR_SYS_CLONE 17
+
+# define NETDATA_KEY_CALLS_VFS_WRITEV 18
+# define NETDATA_KEY_ERROR_VFS_WRITEV 19
+# define NETDATA_KEY_BYTES_VFS_WRITEV 20
+
+# define NETDATA_KEY_CALLS_VFS_READV 21
+# define NETDATA_KEY_ERROR_VFS_READV 22
+# define NETDATA_KEY_BYTES_VFS_READV 23
#endif