summaryrefslogtreecommitdiffstats
path: root/src/collectors/ebpf.plugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/collectors/ebpf.plugin')
-rw-r--r--src/collectors/ebpf.plugin/ebpf.c48
-rw-r--r--src/collectors/ebpf.plugin/ebpf_apps.c18
-rw-r--r--src/collectors/ebpf.plugin/ebpf_apps.h2
-rw-r--r--src/collectors/ebpf.plugin/ebpf_functions.c5
4 files changed, 7 insertions, 66 deletions
diff --git a/src/collectors/ebpf.plugin/ebpf.c b/src/collectors/ebpf.plugin/ebpf.c
index c46688895f..5c2036394e 100644
--- a/src/collectors/ebpf.plugin/ebpf.c
+++ b/src/collectors/ebpf.plugin/ebpf.c
@@ -3051,48 +3051,6 @@ static inline void ebpf_load_thread_config()
}
/**
- * Check Conditions
- *
- * This function checks kernel that plugin is running and permissions.
- *
- * @return It returns 0 on success and -1 otherwise
- */
-int ebpf_check_conditions()
-{
- if (!has_condition_to_run(running_on_kernel)) {
- netdata_log_error("The current collector cannot run on this kernel.");
- return -1;
- }
-
- if (!am_i_running_as_root()) {
- netdata_log_error(
- "ebpf.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities..",
- (unsigned int)getuid(), (unsigned int)geteuid());
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Adjust memory
- *
- * Adjust memory values to load eBPF programs.
- *
- * @return It returns 0 on success and -1 otherwise
- */
-int ebpf_adjust_memory_limit()
-{
- struct rlimit r = { RLIM_INFINITY, RLIM_INFINITY };
- if (setrlimit(RLIMIT_MEMLOCK, &r)) {
- netdata_log_error("Setrlimit(RLIMIT_MEMLOCK)");
- return -1;
- }
-
- return 0;
-}
-
-/**
* Parse arguments given from user.
*
* @param argc the number of arguments
@@ -3324,7 +3282,7 @@ static void ebpf_parse_args(int argc, char **argv)
case EBPF_OPTION_UNITTEST: {
// if we cannot run until the end, we will cancel the unittest
int exit_code = ECANCELED;
- if (ebpf_check_conditions())
+ if (ebpf_can_plugin_load_code(running_on_kernel, NETDATA_EBPF_PLUGIN_NAME))
goto unittest;
if (ebpf_adjust_memory_limit())
@@ -4009,7 +3967,7 @@ static void ebpf_manage_pid(pid_t pid)
int main(int argc, char **argv)
{
clocks_init();
- nd_log_initialize_for_external_plugins("ebpf.plugin");
+ nd_log_initialize_for_external_plugins(NETDATA_EBPF_PLUGIN_NAME);
main_thread_id = gettid();
@@ -4017,7 +3975,7 @@ int main(int argc, char **argv)
ebpf_parse_args(argc, argv);
ebpf_manage_pid(getpid());
- if (ebpf_check_conditions())
+ if (ebpf_can_plugin_load_code(running_on_kernel, NETDATA_EBPF_PLUGIN_NAME))
return 2;
if (ebpf_adjust_memory_limit())
diff --git a/src/collectors/ebpf.plugin/ebpf_apps.c b/src/collectors/ebpf.plugin/ebpf_apps.c
index e9503d1db1..544f468523 100644
--- a/src/collectors/ebpf.plugin/ebpf_apps.c
+++ b/src/collectors/ebpf.plugin/ebpf_apps.c
@@ -372,24 +372,6 @@ int ebpf_read_hash_table(void *ep, int fd, uint32_t pid)
*****************************************************************/
/**
- * Am I running as Root
- *
- * Verify the user that is running the collector.
- *
- * @return It returns 1 for root and 0 otherwise.
- */
-int am_i_running_as_root()
-{
- uid_t uid = getuid(), euid = geteuid();
-
- if (uid == 0 || euid == 0) {
- return 1;
- }
-
- return 0;
-}
-
-/**
* Reset the target values
*
* @param root the pointer to the chain that will be reset.
diff --git a/src/collectors/ebpf.plugin/ebpf_apps.h b/src/collectors/ebpf.plugin/ebpf_apps.h
index feffe74218..12f2f54fec 100644
--- a/src/collectors/ebpf.plugin/ebpf_apps.h
+++ b/src/collectors/ebpf.plugin/ebpf_apps.h
@@ -195,8 +195,6 @@ void clean_apps_groups_target(struct ebpf_target *apps_groups_root_target);
size_t zero_all_targets(struct ebpf_target *root);
-int am_i_running_as_root();
-
void cleanup_exited_pids();
int ebpf_read_hash_table(void *ep, int fd, uint32_t pid);
diff --git a/src/collectors/ebpf.plugin/ebpf_functions.c b/src/collectors/ebpf.plugin/ebpf_functions.c
index 7876c9b945..437d1234b2 100644
--- a/src/collectors/ebpf.plugin/ebpf_functions.c
+++ b/src/collectors/ebpf.plugin/ebpf_functions.c
@@ -116,7 +116,10 @@ static void ebpf_fill_function_buffer(BUFFER *wb, netdata_socket_plus_t *values,
buffer_json_add_array_item_uint64(wb, (uint64_t)values->pid);
// NAME
- buffer_json_add_array_item_string(wb, (name) ? name : "unknown");
+ if (!values->data.name[0])
+ buffer_json_add_array_item_string(wb, (name) ? name : "unknown");
+ else
+ buffer_json_add_array_item_string(wb, values->data.name);
// Origin
buffer_json_add_array_item_string(wb, (values->data.external_origin) ? "in" : "out");