@cryptotaxi247 / netdata-1 / commits / 3a96ef03b

Add user plugin dirs to environment (#13203)

Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>

Vladimir Kobal committed Jun 24, 2022 at 11:32 UTC 3a96ef03b97c885122a4950733b8b01cb0fac69e
2 files changed +15
collectors/plugins.d/README.md
+1
@@ -151,6 +151,7 @@ available for the plugin to use.
151 |`NETDATA_USER_CONFIG_DIR`|The directory where all Netdata-related user configuration should be stored. If the plugin requires custom user configuration, this is the place the user has saved it (normally under `/etc/netdata`).|
152 |`NETDATA_STOCK_CONFIG_DIR`|The directory where all Netdata -related stock configuration should be stored. If the plugin is shipped with configuration files, this is the place they can be found (normally under `/usr/lib/netdata/conf.d`).|
153 |`NETDATA_PLUGINS_DIR`|The directory where all Netdata plugins are stored.|
154 +|`NETDATA_USER_PLUGINS_DIRS`|The list of directories where custom plugins are stored.|
155 |`NETDATA_WEB_DIR`|The directory where the web files of Netdata are saved.|
156 |`NETDATA_CACHE_DIR`|The directory where the cache files of Netdata are stored. Use this directory if the plugin requires a place to store data. A new directory should be created for the plugin for this purpose, inside this directory.|
157 |`NETDATA_LOG_DIR`|The directory where the log files are stored. By default the `stderr` output of the plugin will be saved in the `error.log` file of Netdata.|
daemon/analytics.c
+14
@@ -847,6 +847,20 @@ void set_global_environment()
847 setenv("HOME", verify_required_directory(netdata_configured_home_dir), 1);
848 setenv("NETDATA_HOST_PREFIX", netdata_configured_host_prefix, 1);
849
850 + {
851 + BUFFER *user_plugins_dirs = buffer_create(FILENAME_MAX);
852 +
853 + for (size_t i = 1; i < PLUGINSD_MAX_DIRECTORIES && plugin_directories[i]; i++) {
854 + if (i > 1)
855 + buffer_strcat(user_plugins_dirs, " ");
856 + buffer_strcat(user_plugins_dirs, plugin_directories[i]);
857 + }
858 +
859 + setenv("NETDATA_USER_PLUGINS_DIRS", buffer_tostring(user_plugins_dirs), 1);
860 +
861 + buffer_free(user_plugins_dirs);
862 + }
863 +
864 analytics_data.data_length = 0;
865 analytics_set_data(&analytics_data.netdata_config_stream_enabled, "null");
866 analytics_set_data(&analytics_data.netdata_config_memory_mode, "null");