@cryptotaxi247 / netdata-1 / commits / c226f1b42

Ebpf index size (#8743)

Adjusts the index size inside eBPF collector to avoid reset on indexes.

thiagoftsm committed Apr 20, 2020 at 20:16 UTC c226f1b42ab935870a32ea6408699e7af1768a27
2 files changed +69 -25
collectors/ebpf_process.plugin/ebpf_process.c
+25 -25
@@ -73,7 +73,7 @@ struct config collector_config;
73 static int mykernel = 0;
74 static int nprocs;
75 static int isrh;
76 -uint32_t *hash_values;
76 +netdata_idx_t *hash_values;
77
78 pthread_mutex_t lock;
79
@@ -511,15 +511,15 @@ void *process_publisher(void *ptr)
511 }
512
513 static void move_from_kernel2user_global() {
514 - uint32_t idx;
515 - uint32_t res[NETDATA_GLOBAL_VECTOR];
514 + uint64_t idx;
515 + netdata_idx_t res[NETDATA_GLOBAL_VECTOR];
516
517 - uint32_t *val = hash_values;
517 + netdata_idx_t *val = hash_values;
518 for (idx = 0; idx < NETDATA_GLOBAL_VECTOR; idx++) {
519 if(!bpf_map_lookup_elem(map_fd[1], &idx, val)) {
520 - uint32_t total = 0;
520 + uint64_t total = 0;
521 int i;
522 - int end = (mykernel < 265984)?1:nprocs;
522 + int end = (mykernel < NETDATA_KERNEL_V4_15)?1:nprocs;
523 for (i = 0; i < end; i++)
524 total += val[i];
525
@@ -529,26 +529,26 @@ static void move_from_kernel2user_global() {
529 }
530 }
531
532 - aggregated_data[0].call = res[0]; //open
533 - aggregated_data[1].call = res[14]; //close
534 - aggregated_data[2].call = res[8]; //unlink
535 - aggregated_data[3].call = res[5] + res[21]; //read + readv
536 - aggregated_data[4].call = res[2] + res[18]; //write + writev
537 - aggregated_data[5].call = res[10]; //exit
538 - aggregated_data[6].call = res[11]; //release
539 - aggregated_data[7].call = res[12]; //fork
540 - aggregated_data[8].call = res[16]; //thread
532 + aggregated_data[0].call = res[NETDATA_KEY_CALLS_DO_SYS_OPEN];
533 + aggregated_data[1].call = res[NETDATA_KEY_CALLS_CLOSE_FD];
534 + aggregated_data[2].call = res[NETDATA_KEY_CALLS_VFS_UNLINK];
535 + aggregated_data[3].call = res[NETDATA_KEY_CALLS_VFS_READ] + res[NETDATA_KEY_CALLS_VFS_READV];
536 + aggregated_data[4].call = res[NETDATA_KEY_CALLS_VFS_WRITE] + res[NETDATA_KEY_CALLS_VFS_WRITEV];
537 + aggregated_data[5].call = res[NETDATA_KEY_CALLS_DO_EXIT];
538 + aggregated_data[6].call = res[NETDATA_KEY_CALLS_RELEASE_TASK];
539 + aggregated_data[7].call = res[NETDATA_KEY_CALLS_DO_FORK];
540 + aggregated_data[8].call = res[NETDATA_KEY_CALLS_SYS_CLONE];
541
542 - aggregated_data[0].ecall = res[1]; //open
543 - aggregated_data[1].ecall = res[15]; //close
544 - aggregated_data[2].ecall = res[9]; //unlink
545 - aggregated_data[3].ecall = res[6] + res[22]; //read + readv
546 - aggregated_data[4].ecall = res[3] + res[19]; //write + writev
547 - aggregated_data[7].ecall = res[13]; //fork
548 - aggregated_data[8].ecall = res[17]; //thread
542 + aggregated_data[0].ecall = res[NETDATA_KEY_ERROR_DO_SYS_OPEN];
543 + aggregated_data[1].ecall = res[NETDATA_KEY_ERROR_CLOSE_FD];
544 + aggregated_data[2].ecall = res[NETDATA_KEY_ERROR_VFS_UNLINK];
545 + aggregated_data[3].ecall = res[NETDATA_KEY_ERROR_VFS_READ] + res[NETDATA_KEY_ERROR_VFS_READV];
546 + aggregated_data[4].ecall = res[NETDATA_KEY_ERROR_VFS_WRITE] + res[NETDATA_KEY_ERROR_VFS_WRITEV];
547 + aggregated_data[7].ecall = res[NETDATA_KEY_ERROR_DO_FORK];
548 + aggregated_data[8].ecall = res[NETDATA_KEY_ERROR_SYS_CLONE];
549
550 - aggregated_data[2].bytes = (uint64_t)res[4] + (uint64_t)res[20]; //write + writev
551 - aggregated_data[3].bytes = (uint64_t)res[7] + (uint64_t)res[23];//read + readv
550 + aggregated_data[2].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITE] + (uint64_t)res[NETDATA_KEY_BYTES_VFS_WRITEV];
551 + aggregated_data[3].bytes = (uint64_t)res[NETDATA_KEY_BYTES_VFS_READ] + (uint64_t)res[NETDATA_KEY_BYTES_VFS_READV];
552 }
553
554 static void move_from_kernel2user()
@@ -638,7 +638,7 @@ int allocate_global_vectors() {
638 return -1;
639 }
640
641 - hash_values = callocz(nprocs, sizeof(uint32_t));
641 + hash_values = callocz(nprocs, sizeof(netdata_idx_t));
642 if(!hash_values) {
643 return -1;
644 }
collectors/ebpf_process.plugin/ebpf_process.h
+44
@@ -48,6 +48,8 @@ typedef struct netdata_syscall_stat {
48 struct netdata_syscall_stat *next; //Link list
49 }netdata_syscall_stat_t;
50
51 +typedef uint64_t netdata_idx_t;
52 +
53 typedef struct netdata_publish_syscall {
54 char *dimension;
55 char *name;
@@ -76,6 +78,7 @@ typedef struct netdata_error_report {
78 int err;
79 }netdata_error_report_t;
80
81 +//Chart defintions
82 # define NETDATA_EBPF_FAMILY "ebpf"
83 # define NETDATA_FILE_GROUP "File"
84 # define NETDATA_VFS_GROUP "VFS"
@@ -96,10 +99,51 @@ typedef struct netdata_error_report {
99 # define NETDATA_VFS_DIM_IN_FILE_BYTES "write"
100 # define NETDATA_VFS_DIM_OUT_FILE_BYTES "read"
101
102 +//Log file
103 # define NETDATA_DEVELOPER_LOG_FILE "developer.log"
104
105 +//Maximum number of processors monitored on perf events
106 # define NETDATA_MAX_PROCESSOR 512
107
108 +//Kernel versions calculated with the formula:
109 +// R = MAJOR*65536 + MINOR*256 + PATCH
110 # define NETDATA_KERNEL_V5_3 328448
111 +# define NETDATA_KERNEL_V4_15 265984
112 +
113 +//Index from kernel
114 +# define NETDATA_KEY_CALLS_DO_SYS_OPEN 0
115 +# define NETDATA_KEY_ERROR_DO_SYS_OPEN 1
116 +
117 +# define NETDATA_KEY_CALLS_VFS_WRITE 2
118 +# define NETDATA_KEY_ERROR_VFS_WRITE 3
119 +# define NETDATA_KEY_BYTES_VFS_WRITE 4
120 +
121 +# define NETDATA_KEY_CALLS_VFS_READ 5
122 +# define NETDATA_KEY_ERROR_VFS_READ 6
123 +# define NETDATA_KEY_BYTES_VFS_READ 7
124 +
125 +# define NETDATA_KEY_CALLS_VFS_UNLINK 8
126 +# define NETDATA_KEY_ERROR_VFS_UNLINK 9
127 +
128 +# define NETDATA_KEY_CALLS_DO_EXIT 10
129 +
130 +# define NETDATA_KEY_CALLS_RELEASE_TASK 11
131 +
132 +# define NETDATA_KEY_CALLS_DO_FORK 12
133 +# define NETDATA_KEY_ERROR_DO_FORK 13
134 +
135 +# define NETDATA_KEY_CALLS_CLOSE_FD 14
136 +# define NETDATA_KEY_ERROR_CLOSE_FD 15
137 +
138 +# define NETDATA_KEY_CALLS_SYS_CLONE 16
139 +# define NETDATA_KEY_ERROR_SYS_CLONE 17
140 +
141 +# define NETDATA_KEY_CALLS_VFS_WRITEV 18
142 +# define NETDATA_KEY_ERROR_VFS_WRITEV 19
143 +# define NETDATA_KEY_BYTES_VFS_WRITEV 20
144 +
145 +# define NETDATA_KEY_CALLS_VFS_READV 21
146 +# define NETDATA_KEY_ERROR_VFS_READV 22
147 +# define NETDATA_KEY_BYTES_VFS_READV 23
148
149 #endif