summaryrefslogtreecommitdiffstats
path: root/collectors/ebpf.plugin/ebpf.c
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/ebpf.plugin/ebpf.c')
-rw-r--r--collectors/ebpf.plugin/ebpf.c90
1 files changed, 76 insertions, 14 deletions
diff --git a/collectors/ebpf.plugin/ebpf.c b/collectors/ebpf.plugin/ebpf.c
index 26dacfd3e..5cc005f30 100644
--- a/collectors/ebpf.plugin/ebpf.c
+++ b/collectors/ebpf.plugin/ebpf.c
@@ -77,19 +77,26 @@ 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, .apps_routine = ebpf_process_create_apps_charts },
+ .optional = 0, .apps_routine = ebpf_process_create_apps_charts, .maps = NULL,
+ .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL},
{ .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, .apps_routine = ebpf_socket_create_apps_charts },
+ .optional = 0, .apps_routine = ebpf_socket_create_apps_charts, .maps = NULL,
+ .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL},
{ .thread_name = "cachestat", .config_name = "cachestat", .enabled = 0, .start_routine = ebpf_cachestat_thread,
- .update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
- .optional = 0, .apps_routine = ebpf_cachestat_create_apps_charts },
+ .update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
+ .optional = 0, .apps_routine = ebpf_cachestat_create_apps_charts, .maps = NULL,
+ .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL},
{ .thread_name = "sync", .config_name = "sync", .enabled = 0, .start_routine = ebpf_sync_thread,
- .update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
- .optional = 0, .apps_routine = NULL },
+ .update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
+ .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL },
+ { .thread_name = "dc", .config_name = "dc", .enabled = 0, .start_routine = ebpf_dcstat_thread,
+ .update_time = 1, .global_charts = 1, .apps_charts = 1, .mode = MODE_ENTRY,
+ .optional = 0, .apps_routine = ebpf_dcstat_create_apps_charts, .maps = NULL,
+ .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE },
{ .thread_name = NULL, .enabled = 0, .start_routine = NULL, .update_time = 1,
.global_charts = 0, .apps_charts = 1, .mode = MODE_ENTRY,
- .optional = 0, .apps_routine = NULL },
+ .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = 0, .names = NULL },
};
// Link with apps.plugin
@@ -130,7 +137,23 @@ static void ebpf_exit(int sig)
return;
}
- freez(global_process_stat);
+ if (ebpf_modules[EBPF_MODULE_SOCKET_IDX].enabled) {
+ ebpf_modules[EBPF_MODULE_SOCKET_IDX].enabled = 0;
+ clean_socket_apps_structures();
+ freez(socket_bandwidth_curr);
+ }
+
+ if (ebpf_modules[EBPF_MODULE_CACHESTAT_IDX].enabled) {
+ ebpf_modules[EBPF_MODULE_CACHESTAT_IDX].enabled = 0;
+ clean_cachestat_pid_structures();
+ freez(cachestat_pid);
+ }
+
+ if (ebpf_modules[EBPF_MODULE_DCSTAT_IDX].enabled) {
+ ebpf_modules[EBPF_MODULE_DCSTAT_IDX].enabled = 0;
+ clean_dcstat_pid_structures();
+ freez(dcstat_pid);
+ }
/*
int ret = fork();
@@ -154,7 +177,7 @@ static void ebpf_exit(int sig)
int sid = setsid();
if (sid >= 0) {
debug(D_EXIT, "Wait for father %d die", getpid());
- sleep_usec(200000); // Sleep 200 miliseconds to father dies.
+ sleep_usec(200000); // Sleep 200 milliseconds to father dies.
clean_loaded_events();
} else {
error("Cannot become session id leader, so I won't try to clean kprobe_events.\n");
@@ -318,7 +341,7 @@ void write_io_chart(char *chart, char *family, char *dwrite, long long vwrite, c
* @param id chart id
* @param title chart title
* @param units units label
- * @param family group name used to attach the chart on dashaboard
+ * @param family group name used to attach the chart on dashboard
* @param charttype chart type
* @param context chart context
* @param order chart order
@@ -376,7 +399,7 @@ void ebpf_create_global_dimension(void *ptr, int end)
* @param id chart id
* @param title chart title
* @param units axis label
- * @param family group name used to attach the chart on dashaboard
+ * @param family group name used to attach the chart on dashboard
* @param context chart context
* @param charttype chart type
* @param order order number of the specified chart
@@ -572,6 +595,8 @@ void ebpf_print_help()
"\n"
" --cachestat or -c Enable charts related to process run time.\n"
"\n"
+ " --dcstat or -d Enable charts related to directory cache.\n"
+ "\n"
" --net or -n Enable network viewer charts.\n"
"\n"
" --process or -p Enable charts related to process run time.\n"
@@ -691,7 +716,7 @@ static void read_local_addresses()
}
/**
- * Start Ptherad Variable
+ * Start Pthread Variable
*
* This function starts all pthread variables.
*
@@ -764,6 +789,22 @@ static void ebpf_update_interval()
}
/**
+ * Update PID table size
+ *
+ * Update default size with value from user
+ */
+static void ebpf_update_table_size()
+{
+ int i;
+ uint32_t value = (uint32_t) appconfig_get_number(&collector_config, EBPF_GLOBAL_SECTION,
+ EBPF_CFG_PID_SIZE, ND_EBPF_DEFAULT_PID_SIZE);
+ for (i = 0; ebpf_modules[i].thread_name; i++) {
+ ebpf_modules[i].pid_map_size = value;
+ }
+}
+
+
+/**
* Read collector values
*
* @param disable_apps variable to store information related to apps.
@@ -783,6 +824,8 @@ static void read_collector_values(int *disable_apps)
ebpf_update_interval();
+ ebpf_update_table_size();
+
// This is kept to keep compatibility
uint32_t enabled = appconfig_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, "disable apps",
CONFIG_BOOLEAN_NO);
@@ -844,6 +887,13 @@ static void read_collector_values(int *disable_apps)
started++;
}
+ enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "dcstat",
+ CONFIG_BOOLEAN_NO);
+ if (enabled) {
+ ebpf_enable_chart(EBPF_MODULE_DCSTAT_IDX, *disable_apps);
+ started++;
+ }
+
if (!started){
ebpf_enable_all_charts(*disable_apps);
// Read network viewer section
@@ -927,6 +977,7 @@ static void parse_args(int argc, char **argv)
{"global", no_argument, 0, 'g' },
{"all", no_argument, 0, 'a' },
{"cachestat", no_argument, 0, 'c' },
+ {"dcstat", no_argument, 0, 'd' },
{"net", no_argument, 0, 'n' },
{"process", no_argument, 0, 'p' },
{"return", no_argument, 0, 'r' },
@@ -945,7 +996,7 @@ static void parse_args(int argc, char **argv)
}
while (1) {
- int c = getopt_long(argc, argv, "hvgcanprs", long_options, &option_index);
+ int c = getopt_long(argc, argv, "hvgacdnprs", long_options, &option_index);
if (c == -1)
break;
@@ -983,6 +1034,15 @@ static void parse_args(int argc, char **argv)
#endif
break;
}
+ case 'd': {
+ enabled = 1;
+ ebpf_enable_chart(EBPF_MODULE_DCSTAT_IDX, disable_apps);
+#ifdef NETDATA_INTERNAL_CHECKS
+ info(
+ "EBPF enabling \"DCSTAT\" charts, because it was started with the option \"--dcstat\" or \"-d\".");
+#endif
+ break;
+ }
case 'n': {
enabled = 1;
ebpf_enable_chart(EBPF_MODULE_SOCKET_IDX, disable_apps);
@@ -1027,7 +1087,7 @@ static void parse_args(int argc, char **argv)
if (load_collector_config(ebpf_user_config_dir, &disable_apps)) {
info(
- "Does not have a configuration file inside `%s/ebpf.conf. It will try to load stock file.",
+ "Does not have a configuration file inside `%s/ebpf.d.conf. It will try to load stock file.",
ebpf_user_config_dir);
if (load_collector_config(ebpf_stock_config_dir, &disable_apps)) {
info("Does not have a stock file. It is starting with default options.");
@@ -1141,6 +1201,8 @@ int main(int argc, char **argv)
NULL, NULL, ebpf_modules[EBPF_MODULE_CACHESTAT_IDX].start_routine},
{"EBPF SYNC" , NULL, NULL, 1,
NULL, NULL, ebpf_modules[EBPF_MODULE_SYNC_IDX].start_routine},
+ {"EBPF DCSTAT" , NULL, NULL, 1,
+ NULL, NULL, ebpf_modules[EBPF_MODULE_DCSTAT_IDX].start_routine},
{NULL , NULL, NULL, 0,
NULL, NULL, NULL}
};