@cryptotaxi247 / netdata-1 / commits / 9d7b2c977

prevent unecessary error log when streaming is disabled

Costa Tsaousis (ktsaou) committed Feb 24, 2017 at 22:45 UTC 9d7b2c977ce57ae3828343d30f930f6b45ce1bcd
2 files changed +13 -10
src/main.c
+3
@@ -384,6 +384,9 @@ static void backwards_compatible_config() {
384 if(config_exists(CONFIG_SECTION_GLOBAL, "respect web browser do not track policy") && !config_exists(CONFIG_SECTION_API, "respect do not track policy"))
385 config_move(CONFIG_SECTION_GLOBAL, "respect web browser do not track policy", CONFIG_SECTION_API, "respect do not track policy");
386
387 + if(config_exists(CONFIG_SECTION_GLOBAL, "web x-frame-options header") && !config_exists(CONFIG_SECTION_API, "x-frame-options header"))
388 + config_move(CONFIG_SECTION_GLOBAL, "web x-frame-options header", CONFIG_SECTION_API, "x-frame-options header");
389 +
390 if(config_exists(CONFIG_SECTION_GLOBAL, "enable web responses gzip compression") && !config_exists(CONFIG_SECTION_API, "gzip compression"))
391 config_move(CONFIG_SECTION_GLOBAL, "enable web responses gzip compression", CONFIG_SECTION_API, "gzip compression");
392
src/rrdpush.c
+10 -10
@@ -24,15 +24,15 @@
24 */
25
26 int default_rrdpush_enabled = 0;
27 -static char *remote_netdata_config = NULL;
28 -static char *api_key = NULL;
27 +static char *rrdpush_destination = NULL;
28 +static char *rrdpush_api_key = NULL;
29
30 int rrdpush_init() {
31 default_rrdpush_enabled = config_get_boolean(CONFIG_SECTION_STREAM, "enabled", default_rrdpush_enabled);
32 - remote_netdata_config = config_get(CONFIG_SECTION_STREAM, "stream metrics to", "");
33 - api_key = config_get(CONFIG_SECTION_STREAM, "api key", "");
32 + rrdpush_destination = config_get(CONFIG_SECTION_STREAM, "destination", "");
33 + rrdpush_api_key = config_get(CONFIG_SECTION_STREAM, "api key", "");
34
35 - if(!default_rrdpush_enabled || !remote_netdata_config || !*remote_netdata_config || !api_key || !*api_key) {
35 + if(default_rrdpush_enabled && (!rrdpush_destination || !*rrdpush_destination || !rrdpush_api_key || !*rrdpush_api_key)) {
36 error("STREAM [send]: cannot enable sending thread - information is missing.");
37 default_rrdpush_enabled = 0;
38 }
@@ -244,7 +244,7 @@ void *rrdpush_sender_thread(void *ptr) {
244 remote_clock_resync_iterations = (unsigned int)config_get_number(CONFIG_SECTION_STREAM, "initial clock resync iterations", remote_clock_resync_iterations);
245 char connected_to[CONNECTED_TO_SIZE + 1] = "";
246
247 - if(!host->rrdpush_enabled || !remote_netdata_config || !*remote_netdata_config || !api_key || !*api_key)
247 + if(!host->rrdpush_enabled || !rrdpush_destination || !*rrdpush_destination || !rrdpush_api_key || !*rrdpush_api_key)
248 goto cleanup;
249
250 // initialize rrdpush globals
@@ -276,11 +276,11 @@ void *rrdpush_sender_thread(void *ptr) {
276 // they will be lost, so there is no point to do it
277 host->rrdpush_connected = 0;
278
279 - info("STREAM [send to %s]: connecting...", remote_netdata_config);
280 - host->rrdpush_socket = connect_to_one_of(remote_netdata_config, default_port, &tv, &reconnects_counter, connected_to, CONNECTED_TO_SIZE);
279 + info("STREAM [send to %s]: connecting...", rrdpush_destination);
280 + host->rrdpush_socket = connect_to_one_of(rrdpush_destination, default_port, &tv, &reconnects_counter, connected_to, CONNECTED_TO_SIZE);
281
282 if(unlikely(host->rrdpush_socket == -1)) {
283 - error("STREAM [send to %s]: failed to connect", remote_netdata_config);
283 + error("STREAM [send to %s]: failed to connect", rrdpush_destination);
284 sleep(reconnect_delay);
285 continue;
286 }
@@ -292,7 +292,7 @@ void *rrdpush_sender_thread(void *ptr) {
292 "STREAM key=%s&hostname=%s&machine_guid=%s&os=%s&update_every=%d HTTP/1.1\r\n"
293 "User-Agent: netdata-push-service/%s\r\n"
294 "Accept: */*\r\n\r\n"
295 - , api_key
295 + , rrdpush_api_key
296 , localhost->hostname
297 , localhost->machine_guid
298 , localhost->os