summaryrefslogtreecommitdiffstats
path: root/collectors
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2021-02-25 16:17:36 +0000
committerGitHub <noreply@github.com>2021-02-25 16:17:36 +0000
commit2bddc7a0f4ad406bf45f526a853b3d025839bc3b (patch)
tree88d38e782653dea812965005f993fc6cca4cb116 /collectors
parent01a978b1b64491ce65843624450aae7bc9da714e (diff)
Ebpf support new collectors (#10680)
Extend original support from kprobe for all available eBPF programs and allow `eBPF.plugin` to use some Netdata features.
Diffstat (limited to 'collectors')
-rw-r--r--collectors/ebpf.plugin/ebpf.c53
-rw-r--r--collectors/ebpf.plugin/ebpf.h5
-rw-r--r--collectors/ebpf.plugin/ebpf_process.c24
-rw-r--r--collectors/ebpf.plugin/ebpf_socket.c15
4 files changed, 63 insertions, 34 deletions
diff --git a/collectors/ebpf.plugin/ebpf.c b/collectors/ebpf.plugin/ebpf.c
index 26bcfcf179..3f84f817db 100644
--- a/collectors/ebpf.plugin/ebpf.c
+++ b/collectors/ebpf.plugin/ebpf.c
@@ -79,13 +79,13 @@ pthread_cond_t collect_data_cond_var;
ebpf_module_t ebpf_modules[] = {
{ .thread_name = "process", .config_name = "process", .enabled = 0, .start_routine = ebpf_process_thread,
.update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
- .optional = 0 },
+ .optional = 0, .apps_routine = ebpf_process_create_apps_charts },
{ .thread_name = "socket", .config_name = "socket", .enabled = 0, .start_routine = ebpf_socket_thread,
.update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
- .optional = 0 },
+ .optional = 0, .apps_routine = ebpf_socket_create_apps_charts },
{ .thread_name = NULL, .enabled = 0, .start_routine = NULL, .update_time = 1,
.global_charts = 0, .apps_charts = 1, .mode = MODE_ENTRY,
- .optional = 0 },
+ .optional = 0, .apps_routine = NULL },
};
// Link with apps.plugin
@@ -343,23 +343,26 @@ void write_io_chart(char *chart, char *family, char *dwrite, long long vwrite, c
/**
* Write chart cmd on standard output
*
- * @param type the chart type
- * @param id the chart id
- * @param title the chart title
- * @param units the units label
- * @param family the group name used to attach the chart on dashaboard
- * @param charttype the chart type
- * @param order the chart order
+ * @param type chart type
+ * @param id chart id
+ * @param title chart title
+ * @param units units label
+ * @param family group name used to attach the chart on dashaboard
+ * @param charttype chart type
+ * @param context chart context
+ * @param order chart order
*/
-void ebpf_write_chart_cmd(char *type, char *id, char *title, char *units, char *family, char *charttype, int order)
+void ebpf_write_chart_cmd(char *type, char *id, char *title, char *units, char *family,
+ char *charttype, char *context, int order)
{
- printf("CHART %s.%s '' '%s' '%s' '%s' '' %s %d %d\n",
+ printf("CHART %s.%s '' '%s' '%s' '%s' '%s' '%s' %d %d\n",
type,
id,
title,
units,
- family,
- charttype,
+ (family)?family:"",
+ (context)?context:"",
+ (charttype)?charttype:"",
order,
update_every);
}
@@ -398,26 +401,28 @@ void ebpf_create_global_dimension(void *ptr, int end)
/**
* Call write_chart_cmd to create the charts
*
- * @param type the chart type
- * @param id the chart id
- * @param units the axis label
- * @param family the group name used to attach the chart on dashaboard
- * @param order the order number of the specified chart
- * @param ncd a pointer to a function called to create dimensions
- * @param move a pointer for a structure that has the dimensions
- * @param end number of dimensions for the chart created
+ * @param type chart type
+ * @param id chart id
+ * @param units axis label
+ * @param family group name used to attach the chart on dashaboard
+ * @param order order number of the specified chart
+ * @param context chart context
+ * @param ncd a pointer to a function called to create dimensions
+ * @param move a pointer for a structure that has the dimensions
+ * @param end number of dimensions for the chart created
*/
void ebpf_create_chart(char *type,
char *id,
char *title,
char *units,
char *family,
+ char *context,
int order,
void (*ncd)(void *, int),
void *move,
int end)
{
- ebpf_write_chart_cmd(type, id, title, units, family, "line", order);
+ ebpf_write_chart_cmd(type, id, title, units, family, "line", context, order);
ncd(move, end);
}
@@ -437,7 +442,7 @@ void ebpf_create_charts_on_apps(char *id, char *title, char *units, char *family
char *algorithm, struct target *root)
{
struct target *w;
- ebpf_write_chart_cmd(NETDATA_APPS_FAMILY, id, title, units, family, "stacked", order);
+ ebpf_write_chart_cmd(NETDATA_APPS_FAMILY, id, title, units, family, "stacked", NULL, order);
for (w = root; w; w = w->next) {
if (unlikely(w->exposed))
diff --git a/collectors/ebpf.plugin/ebpf.h b/collectors/ebpf.plugin/ebpf.h
index 35013c2b2e..6a7a214f0c 100644
--- a/collectors/ebpf.plugin/ebpf.h
+++ b/collectors/ebpf.plugin/ebpf.h
@@ -133,6 +133,7 @@ extern void ebpf_write_chart_cmd(char *type,
char *units,
char *family,
char *charttype,
+ char *context,
int order);
extern void ebpf_write_global_dimension(char *name, char *id, char *algorithm);
@@ -144,6 +145,7 @@ extern void ebpf_create_chart(char *type,
char *title,
char *units,
char *family,
+ char *context,
int order,
void (*ncd)(void *, int),
void *move,
@@ -194,7 +196,8 @@ extern char *ebpf_algorithms[];
// Socket functions and variables
// Common functions
-extern void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root);
+extern void ebpf_process_create_apps_charts(struct ebpf_module *em, void *ptr);
+extern void ebpf_socket_create_apps_charts(struct ebpf_module *em, void *ptr);
extern collected_number get_value_from_structure(char *basis, size_t offset);
extern struct pid_stat *root_of_pids;
extern ebpf_process_stat_t *global_process_stat;
diff --git a/collectors/ebpf.plugin/ebpf_process.c b/collectors/ebpf.plugin/ebpf_process.c
index 27e39d1a5e..677b7db635 100644
--- a/collectors/ebpf.plugin/ebpf_process.c
+++ b/collectors/ebpf.plugin/ebpf_process.c
@@ -520,6 +520,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Open and close calls",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_FILE_GROUP,
+ NULL,
21000,
ebpf_create_global_dimension,
process_publish_aggregated,
@@ -531,6 +532,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Open fails",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_FILE_GROUP,
+ NULL,
21001,
ebpf_create_global_dimension,
process_publish_aggregated,
@@ -542,6 +544,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Remove files",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_VFS_GROUP,
+ NULL,
21002,
ebpf_create_global_dimension,
&process_publish_aggregated[NETDATA_DEL_START],
@@ -552,6 +555,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Calls to IO",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_VFS_GROUP,
+ NULL,
21003,
ebpf_create_global_dimension,
&process_publish_aggregated[NETDATA_IN_START_BYTE],
@@ -569,6 +573,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Fails to write or read",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_VFS_GROUP,
+ NULL,
21005,
ebpf_create_global_dimension,
&process_publish_aggregated[2],
@@ -580,6 +585,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Start process",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_PROCESS_GROUP,
+ NULL,
21006,
ebpf_create_global_dimension,
&process_publish_aggregated[NETDATA_PROCESS_START],
@@ -590,6 +596,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Exit process",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_PROCESS_GROUP,
+ NULL,
21007,
ebpf_create_global_dimension,
&process_publish_aggregated[NETDATA_EXIT_START],
@@ -608,6 +615,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Fails to create process",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_PROCESS_GROUP,
+ NULL,
21009,
ebpf_create_global_dimension,
&process_publish_aggregated[NETDATA_PROCESS_START],
@@ -621,10 +629,11 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
* Call ebpf_create_chart to create the charts on apps submenu.
*
* @param em a pointer to the structure with the default values.
- * @param root a pointer for the targets.
+ * @param ptr a pointer for the targets.
*/
-static void ebpf_process_create_apps_charts(ebpf_module_t *em, struct target *root)
+void ebpf_process_create_apps_charts(struct ebpf_module *em, void *ptr)
{
+ struct target *root = ptr;
ebpf_create_charts_on_apps(NETDATA_SYSCALL_APPS_FILE_OPEN,
"Number of open files",
EBPF_COMMON_DIMENSION_CALL,
@@ -786,11 +795,12 @@ static void ebpf_create_apps_charts(ebpf_module_t *em, struct target *root)
if (!newly_added)
return;
- if (ebpf_modules[EBPF_MODULE_PROCESS_IDX].apps_charts)
- ebpf_process_create_apps_charts(em, root);
-
- if (ebpf_modules[EBPF_MODULE_SOCKET_IDX].apps_charts)
- ebpf_socket_create_apps_charts(NULL, root);
+ int counter;
+ for (counter = 0; ebpf_modules[counter].thread_name; counter++) {
+ ebpf_module_t *current = &ebpf_modules[counter];
+ if (current->apps_charts && current->apps_routine)
+ current->apps_routine(em, root);
+ }
}
/*****************************************************************
diff --git a/collectors/ebpf.plugin/ebpf_socket.c b/collectors/ebpf.plugin/ebpf_socket.c
index 7fbc244217..9776fb7cdc 100644
--- a/collectors/ebpf.plugin/ebpf_socket.c
+++ b/collectors/ebpf.plugin/ebpf_socket.c
@@ -427,6 +427,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Calls to internal functions",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_SOCKET_GROUP,
+ NULL,
21070,
ebpf_create_global_dimension,
socket_publish_aggregated,
@@ -435,6 +436,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
ebpf_create_chart(NETDATA_EBPF_FAMILY, NETDATA_TCP_FUNCTION_BITS,
"TCP bandwidth", EBPF_COMMON_DIMENSION_BITS,
NETDATA_SOCKET_GROUP,
+ NULL,
21071,
ebpf_create_global_dimension,
socket_publish_aggregated,
@@ -446,6 +448,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"TCP errors",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_SOCKET_GROUP,
+ NULL,
21072,
ebpf_create_global_dimension,
socket_publish_aggregated,
@@ -457,6 +460,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"Packages retransmitted",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_SOCKET_GROUP,
+ NULL,
21073,
ebpf_create_global_dimension,
&socket_publish_aggregated[NETDATA_RETRANSMIT_START],
@@ -467,6 +471,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"UDP calls",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_SOCKET_GROUP,
+ NULL,
21074,
ebpf_create_global_dimension,
&socket_publish_aggregated[NETDATA_UDP_START],
@@ -475,6 +480,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
ebpf_create_chart(NETDATA_EBPF_FAMILY, NETDATA_UDP_FUNCTION_BITS,
"UDP bandwidth", EBPF_COMMON_DIMENSION_BITS,
NETDATA_SOCKET_GROUP,
+ NULL,
21075,
ebpf_create_global_dimension,
&socket_publish_aggregated[NETDATA_UDP_START],
@@ -486,6 +492,7 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
"UDP errors",
EBPF_COMMON_DIMENSION_CALL,
NETDATA_SOCKET_GROUP,
+ NULL,
21076,
ebpf_create_global_dimension,
&socket_publish_aggregated[NETDATA_UDP_START],
@@ -498,11 +505,13 @@ static void ebpf_create_global_charts(ebpf_module_t *em)
*
* Call ebpf_create_chart to create the charts on apps submenu.
*
- * @param em a pointer to the structure with the default values.
+ * @param em a pointer to the structure with the default values.
+ * @param ptr a pointer for targets
*/
-void ebpf_socket_create_apps_charts(ebpf_module_t *em, struct target *root)
+void ebpf_socket_create_apps_charts(struct ebpf_module *em, void *ptr)
{
UNUSED(em);
+ struct target *root = ptr;;
ebpf_create_charts_on_apps(NETDATA_NET_APPS_BANDWIDTH_SENT,
"Bytes sent", EBPF_COMMON_DIMENSION_BITS,
NETDATA_APPS_NET_GROUP,
@@ -581,6 +590,7 @@ static void ebpf_socket_create_nv_chart(char *id, char *title, char *units,
units,
family,
"stacked",
+ NULL,
order);
uint32_t i;
@@ -617,6 +627,7 @@ static void ebpf_socket_create_nv_retransmit(char *id, char *title, char *units,
units,
family,
"stacked",
+ NULL,
order);
uint32_t i;