summaryrefslogtreecommitdiffstats
path: root/streaming
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2018-10-17 17:18:59 +0300
committerGitHub <noreply@github.com>2018-10-17 17:18:59 +0300
commitca4c305969e4fdfd2ceea3b8b93c32ad74ebf66d (patch)
tree7895ed67c0453de6635ab1f8faf98923da813576 /streaming
parentad3ff17ac19546d24812daa6f0eca62301e296fa (diff)
moved stream.conf initialization after log files have been open; fixes #4403 (#4422)
Diffstat (limited to 'streaming')
-rw-r--r--streaming/rrdpush.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/streaming/rrdpush.c b/streaming/rrdpush.c
index 5d28206049..df8ee69dcf 100644
--- a/streaming/rrdpush.c
+++ b/streaming/rrdpush.c
@@ -32,12 +32,42 @@ typedef enum {
RRDPUSH_MULTIPLE_CONNECTIONS_DENY_NEW
} RRDPUSH_MULTIPLE_CONNECTIONS_STRATEGY;
+static struct config stream_config = {
+ .sections = NULL,
+ .mutex = NETDATA_MUTEX_INITIALIZER,
+ .index = {
+ .avl_tree = {
+ .root = NULL,
+ .compar = appconfig_section_compare
+ },
+ .rwlock = AVL_LOCK_INITIALIZER
+ }
+};
+
unsigned int default_rrdpush_enabled = 0;
char *default_rrdpush_destination = NULL;
char *default_rrdpush_api_key = NULL;
char *default_rrdpush_send_charts_matching = NULL;
+static void load_stream_conf() {
+ errno = 0;
+ char *filename = strdupz_path_subpath(netdata_configured_user_config_dir, "stream.conf");
+ if(!appconfig_load(&stream_config, filename, 0)) {
+ info("CONFIG: cannot load user config '%s'. Will try stock config.", filename);
+ freez(filename);
+
+ filename = strdupz_path_subpath(netdata_configured_stock_config_dir, "stream.conf");
+ if(!appconfig_load(&stream_config, filename, 0))
+ info("CONFIG: cannot load stock config '%s'. Running with internal defaults.", filename);
+ }
+ freez(filename);
+}
+
int rrdpush_init() {
+ // --------------------------------------------------------------------
+ // load stream.conf
+ load_stream_conf();
+
default_rrdpush_enabled = (unsigned int)appconfig_get_boolean(&stream_config, CONFIG_SECTION_STREAM, "enabled", default_rrdpush_enabled);
default_rrdpush_destination = appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "destination", "");
default_rrdpush_api_key = appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "api key", "");