Browse Source

allow disabling netdata monitoring section of the dashboard (#13788)

* allow disabling netdata monitoring section of the dashboard

* disable-netdata-stats: Modify eBPF.plugin to disable statistic charts according user selection, by default it is enabled

* Don't send internal statistics for exporting engine if it's disabled.

* Fix global statistics flag initialization

* Don't send internal statistics for checks plugin if it's disabled.

Co-authored-by: Thiago Marques <thiagoftsm@gmail.com>
Co-authored-by: Vladimir Kobal <vlad@prokk.net>
Costa Tsaousis 2 years ago
parent
commit
61767a8a08

+ 1 - 1
aclk/aclk.c

@@ -686,7 +686,7 @@ void *aclk_main(void *ptr)
     // that send JSON payloads of 10 MB as single messages
     mqtt_wss_set_max_buf_size(mqttwss_client, 25*1024*1024);
 
-    aclk_stats_enabled = config_get_boolean(CONFIG_SECTION_CLOUD, "statistics", CONFIG_BOOLEAN_YES);
+    aclk_stats_enabled = config_get_boolean(CONFIG_SECTION_CLOUD, "statistics", global_statistics_enabled);
     if (aclk_stats_enabled) {
         stats_thread = callocz(1, sizeof(struct aclk_stats_thread));
         stats_thread->thread = mallocz(sizeof(netdata_thread_t));

+ 9 - 1
collectors/apps.plugin/apps_plugin.c

@@ -4777,6 +4777,13 @@ int main(int argc, char **argv) {
     error_log_errors_per_period = 100;
     error_log_throttle_period = 3600;
 
+    bool send_resource_usage = true;
+    {
+        const char *s = getenv("NETDATA_INTERNALS_MONITORING");
+        if(s && *s && strcmp(s, "NO") == 0)
+            send_resource_usage = false;
+    }
+
     // since apps.plugin runs as root, prevent it from opening symbolic links
     procfile_open_flags = O_RDONLY|O_NOFOLLOW;
 
@@ -4904,7 +4911,8 @@ int main(int argc, char **argv) {
         calculate_netdata_statistics();
         normalize_utilization(apps_groups_root_target);
 
-        send_resource_usage_to_netdata(dt);
+        if(send_resource_usage)
+            send_resource_usage_to_netdata(dt);
 
 #ifndef __FreeBSD__
         send_proc_states_count(dt);

+ 3 - 0
collectors/checks.plugin/plugin_checks.c

@@ -12,6 +12,9 @@ static void checks_main_cleanup(void *ptr) {
 }
 
 void *checks_main(void *ptr) {
+    if (!global_statistics_enabled)
+        return NULL;
+
     netdata_thread_cleanup_push(checks_main_cleanup, ptr);
 
     usec_t usec = 0, susec = localhost->rrd_update_every * USEC_PER_SEC, loop_usec = 0, total_susec = 0;

+ 170 - 34
collectors/ebpf.plugin/ebpf.c

@@ -166,40 +166,176 @@ ebpf_module_t ebpf_modules[] = {
 };
 
 struct netdata_static_thread ebpf_threads[] = {
-    {"EBPF PROCESS", NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF SOCKET" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF CACHESTAT" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF SYNC" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF DCSTAT" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF SWAP" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF VFS" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF FILESYSTEM" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF DISK" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF MOUNT" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF FD" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF HARDIRQ" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF SOFTIRQ" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF OOMKILL" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF SHM" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {"EBPF MDFLUSH" , NULL, NULL, 1,
-        NULL, NULL, NULL},
-    {NULL          , NULL, NULL, 0,
-                     NULL, NULL, NULL}
+    {
+        .name = "EBPF PROCESS",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF SOCKET",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF CACHESTAT",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF SYNC",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF DCSTAT",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF SWAP",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF VFS",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF FILESYSTEM",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF DISK",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF MOUNT",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF FD",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF HARDIRQ",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF SOFTIRQ",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF OOMKILL",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF SHM",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = "EBPF MDFLUSH",
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 1,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
+    {
+        .name = NULL,
+        .config_section = NULL,
+        .config_name = NULL,
+        .env_name = NULL,
+        .enabled = 0,
+        .thread = NULL,
+        .init_routine = NULL,
+        .start_routine = NULL
+    },
 };
 
 ebpf_filesystem_partitions_t localfs[] =

+ 8 - 3
collectors/ebpf.plugin/ebpf_cachestat.c

@@ -15,9 +15,14 @@ netdata_cachestat_pid_t *cachestat_vector = NULL;
 static netdata_idx_t cachestat_hash_values[NETDATA_CACHESTAT_END];
 static netdata_idx_t *cachestat_values = NULL;
 
-struct netdata_static_thread cachestat_threads = {"CACHESTAT KERNEL",
-                                                  NULL, NULL, 1, NULL,
-                                                  NULL,  NULL};
+struct netdata_static_thread cachestat_threads = {.name = "CACHESTAT KERNEL",
+                                                  .config_section = NULL,
+                                                  .config_name = NULL,
+                                                  .env_name = NULL,
+                                                  .enabled = 1,
+                                                  .thread = NULL,
+                                                  .init_routine = NULL,
+                                                  .start_routine = NULL};
 
 ebpf_local_maps_t cachestat_maps[] = {{.name = "cstat_global", .internal_input = NETDATA_CACHESTAT_END,
                                               .user_input = 0, .type = NETDATA_EBPF_MAP_STATIC,

+ 7 - 2
collectors/ebpf.plugin/ebpf_dcstat.c

@@ -20,8 +20,13 @@ struct config dcstat_config = { .first_section = NULL,
         .rwlock = AVL_LOCK_INITIALIZER } };
 
 struct netdata_static_thread dcstat_threads = {"DCSTAT KERNEL",
-                                               NULL, NULL, 1, NULL,
-                                               NULL,  NULL};
+                                               .config_section = NULL,
+                                               .config_name = NULL,
+                                               .env_name = NULL,
+                                               .enabled = 1,
+                                               .thread = NULL,
+                                               .init_routine = NULL,
+                                               .start_routine = NULL};
 static enum ebpf_threads_status ebpf_dcstat_exited = NETDATA_THREAD_EBPF_RUNNING;
 
 ebpf_local_maps_t dcstat_maps[] = {{.name = "dcstat_global", .internal_input = NETDATA_DIRECTORY_CACHE_END,

+ 10 - 3
collectors/ebpf.plugin/ebpf_disk.c

@@ -33,9 +33,16 @@ static netdata_syscall_stat_t disk_aggregated_data[NETDATA_EBPF_HIST_MAX_BINS];
 static netdata_publish_syscall_t disk_publish_aggregated[NETDATA_EBPF_HIST_MAX_BINS];
 
 static netdata_idx_t *disk_hash_values = NULL;
-static struct netdata_static_thread disk_threads = {"DISK KERNEL",
-                                                    NULL, NULL, 1, NULL,
-                                                    NULL, NULL };
+static struct netdata_static_thread disk_threads = {
+                                        .name = "DISK KERNEL",
+                                        .config_section = NULL,
+                                        .config_name = NULL,
+                                        .env_name = NULL,
+                                        .enabled = 1,
+                                        .thread = NULL,
+                                        .init_routine = NULL,
+                                        .start_routine = NULL
+};
 static enum ebpf_threads_status ebpf_disk_exited = NETDATA_THREAD_EBPF_RUNNING;
 
 ebpf_publish_disk_t *plot_disks = NULL;

+ 9 - 2
collectors/ebpf.plugin/ebpf_fd.c

@@ -29,8 +29,15 @@ struct config fd_config = { .first_section = NULL, .last_section = NULL, .mutex
                            .index = {.avl_tree = { .root = NULL, .compar = appconfig_section_compare },
                                      .rwlock = AVL_LOCK_INITIALIZER } };
 
-struct netdata_static_thread fd_thread = {"FD KERNEL", NULL, NULL, 1, NULL,
-                                          NULL,  NULL};
+struct netdata_static_thread fd_thread = {"FD KERNEL",
+                                          .config_section = NULL,
+                                          .config_name = NULL,
+                                          .env_name = NULL,
+                                          .enabled = 1,
+                                          .thread = NULL,
+                                          .init_routine = NULL,
+                                          .start_routine = NULL};
+
 static enum ebpf_threads_status ebpf_fd_exited = NETDATA_THREAD_EBPF_RUNNING;
 static netdata_idx_t fd_hash_values[NETDATA_FD_COUNTER];
 static netdata_idx_t *fd_values = NULL;

+ 11 - 3
collectors/ebpf.plugin/ebpf_filesystem.c

@@ -30,9 +30,17 @@ static ebpf_local_maps_t fs_maps[] = {{.name = "tbl_ext4", .internal_input = NET
                                        .type = NETDATA_EBPF_MAP_CONTROLLER,
                                        .map_fd = ND_EBPF_MAP_FD_NOT_INITIALIZED}};
 
-struct netdata_static_thread filesystem_threads = {"EBPF FS READ",
-                                                   NULL, NULL, 1, NULL,
-                                                   NULL, NULL };
+struct netdata_static_thread filesystem_threads = {
+                                 .name = "EBPF FS READ",
+                                 .config_section = NULL,
+                                 .config_name = NULL,
+                                 .env_name = NULL,
+                                 .enabled = 1,
+                                 .thread = NULL,
+                                 .init_routine = NULL,
+                                 .start_routine = NULL
+};
+
 static enum ebpf_threads_status ebpf_fs_exited = NETDATA_THREAD_EBPF_RUNNING;
 
 static netdata_syscall_stat_t filesystem_aggregated_data[NETDATA_EBPF_HIST_MAX_BINS];

+ 10 - 3
collectors/ebpf.plugin/ebpf_hardirq.c

@@ -135,9 +135,16 @@ static hardirq_ebpf_val_t *hardirq_ebpf_vals = NULL;
 // tmp store for static hard IRQ values we get from a per-CPU eBPF map.
 static hardirq_ebpf_static_val_t *hardirq_ebpf_static_vals = NULL;
 
-static struct netdata_static_thread hardirq_threads = {"HARDIRQ KERNEL",
-                                                    NULL, NULL, 1, NULL,
-                                                    NULL, NULL };
+static struct netdata_static_thread hardirq_threads = {
+                                        .name = "HARDIRQ KERNEL",
+                                        .config_section = NULL,
+                                        .config_name = NULL,
+                                        .env_name = NULL,
+                                        .enabled = 1,
+                                        .thread = NULL,
+                                        .init_routine = NULL,
+                                        .start_routine = NULL
+};
 static enum ebpf_threads_status ebpf_hardirq_exited = NETDATA_THREAD_EBPF_RUNNING;
 
 /**

Some files were not shown because too many files changed in this diff