diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-01-26 18:05:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-01-26 18:05:10 +0000 |
commit | 34a0b66bc2d48223748ed1cf5bc1b305c396bd74 (patch) | |
tree | fbd36be86cc6bc4288fe627f2b5beada569848bb /daemon/analytics.c | |
parent | Adding upstream version 1.32.1. (diff) | |
download | netdata-34a0b66bc2d48223748ed1cf5bc1b305c396bd74.tar.xz netdata-34a0b66bc2d48223748ed1cf5bc1b305c396bd74.zip |
Adding upstream version 1.33.0.upstream/1.33.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | daemon/analytics.c | 89 |
1 files changed, 39 insertions, 50 deletions
diff --git a/daemon/analytics.c b/daemon/analytics.c index bb878f70..4501a46a 100644 --- a/daemon/analytics.c +++ b/daemon/analytics.c @@ -1,12 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "common.h" +#include "buildinfo.h" struct analytics_data analytics_data; extern void analytics_exporting_connectors (BUFFER *b); extern void analytics_exporting_connectors_ssl (BUFFER *b); extern void analytics_build_info (BUFFER *b); -extern int aclk_connected; +extern int aclk_connected, aclk_use_new_cloud_arch; struct collector { char *plugin; @@ -52,6 +53,7 @@ void analytics_log_data(void) debug(D_ANALYTICS, "NETDATA_CONFIG_HOSTS_AVAILABLE : [%s]", analytics_data.netdata_config_hosts_available); debug(D_ANALYTICS, "NETDATA_HOST_CLOUD_AVAILABLE : [%s]", analytics_data.netdata_host_cloud_available); debug(D_ANALYTICS, "NETDATA_HOST_ACLK_AVAILABLE : [%s]", analytics_data.netdata_host_aclk_available); + debug(D_ANALYTICS, "NETDATA_HOST_ACLK_PROTOCOL : [%s]", analytics_data.netdata_host_aclk_protocol); debug(D_ANALYTICS, "NETDATA_HOST_ACLK_IMPLEMENTATION : [%s]", analytics_data.netdata_host_aclk_implementation); debug(D_ANALYTICS, "NETDATA_HOST_AGENT_CLAIMED : [%s]", analytics_data.netdata_host_agent_claimed); debug(D_ANALYTICS, "NETDATA_HOST_CLOUD_ENABLED : [%s]", analytics_data.netdata_host_cloud_enabled); @@ -97,6 +99,7 @@ void analytics_free_data(void) freez(analytics_data.netdata_config_hosts_available); freez(analytics_data.netdata_host_cloud_available); freez(analytics_data.netdata_host_aclk_available); + freez(analytics_data.netdata_host_aclk_protocol); freez(analytics_data.netdata_host_aclk_implementation); freez(analytics_data.netdata_host_agent_claimed); freez(analytics_data.netdata_host_cloud_enabled); @@ -357,47 +360,23 @@ void analytics_alarms_notifications(void) buffer_free(b); } -char *get_value_from_key(char *buffer, char *key) -{ - char *s = NULL, *t = NULL; - s = t = buffer + strlen(key) + 2; - if (s) { - while (*s == '\'') - s++; - while (*++t != '\0'); - while (--t > s && *t == '\'') - *t = '\0'; - } - return s; -} - -/* - * Checks for the existence of .install_type file and reads it - */ void analytics_get_install_type(void) { - char *install_type_filename; - analytics_set_data_str(&analytics_data.netdata_install_type, ""); - analytics_set_data_str(&analytics_data.netdata_prebuilt_distro, ""); + struct install_type_info t = get_install_type(); - int install_type_filename_len = (strlen(netdata_configured_user_config_dir) + strlen(".install-type") + 3); - install_type_filename = mallocz(sizeof(char) * install_type_filename_len); - snprintfz(install_type_filename, install_type_filename_len - 1, "%s/%s", netdata_configured_user_config_dir, ".install-type"); + if (t.install_type == NULL) { + analytics_set_data_str(&analytics_data.netdata_install_type, "unknown"); + } else { + analytics_set_data_str(&analytics_data.netdata_install_type, t.install_type); + } - FILE *fp = fopen(install_type_filename, "r"); - if (fp) { - char *s, buf[256 + 1]; - size_t len = 0; - - while ((s = fgets_trim_len(buf, 256, fp, &len))) { - if (!strncmp(buf, "INSTALL_TYPE='", 14)) - analytics_set_data_str(&analytics_data.netdata_install_type, (char *)get_value_from_key(buf, "INSTALL_TYPE")); - else if (!strncmp(buf, "PREBUILT_DISTRO='", 17)) - analytics_set_data_str(&analytics_data.netdata_prebuilt_distro, (char *)get_value_from_key(buf, "PREBUILT_DISTRO")); - } - fclose(fp); + if (t.prebuilt_distro != NULL) { + analytics_set_data_str(&analytics_data.netdata_prebuilt_distro, t.prebuilt_distro); } - freez(install_type_filename); + + freez(t.prebuilt_arch); + freez(t.prebuilt_distro); + freez(t.install_type); } /* @@ -488,28 +467,18 @@ void analytics_alarms(void) } /* - * Misc attributes to get (run from meta) + * Misc attributes to get (run from start) */ void analytics_misc(void) { #ifdef ENABLE_ACLK analytics_set_data(&analytics_data.netdata_host_cloud_available, "true"); - if (aclk_ng) - analytics_set_data_str(&analytics_data.netdata_host_aclk_implementation, "Next Generation"); - else - analytics_set_data_str(&analytics_data.netdata_host_aclk_implementation, "legacy"); + analytics_set_data_str(&analytics_data.netdata_host_aclk_implementation, "Next Generation"); #else analytics_set_data(&analytics_data.netdata_host_cloud_available, "false"); analytics_set_data_str(&analytics_data.netdata_host_aclk_implementation, ""); #endif -#ifdef ENABLE_ACLK - if (aclk_connected) - analytics_set_data(&analytics_data.netdata_host_aclk_available, "true"); - else -#endif - analytics_set_data(&analytics_data.netdata_host_aclk_available, "false"); - analytics_set_data(&analytics_data.netdata_config_exporting_enabled, appconfig_get_boolean(&exporting_config, CONFIG_SECTION_EXPORTING, "enabled", CONFIG_BOOLEAN_NO) ? "true" : "false"); analytics_set_data(&analytics_data.netdata_config_is_private_registry, "false"); @@ -526,6 +495,23 @@ void analytics_misc(void) analytics_set_data(&analytics_data.netdata_config_is_private_registry, "true"); } +void analytics_aclk(void) +{ +#ifdef ENABLE_ACLK + if (aclk_connected) { + analytics_set_data(&analytics_data.netdata_host_aclk_available, "true"); +#ifdef ENABLE_NEW_CLOUD_PROTOCOL + if (aclk_use_new_cloud_arch) + analytics_set_data_str(&analytics_data.netdata_host_aclk_protocol, "New"); + else +#endif + analytics_set_data_str(&analytics_data.netdata_host_aclk_protocol, "Legacy"); + } + else +#endif + analytics_set_data(&analytics_data.netdata_host_aclk_available, "false"); +} + /* * Get the meta data, called from the thread once after the original delay * These are values that won't change during agent runtime, and therefore @@ -551,6 +537,7 @@ void analytics_gather_mutable_meta_data(void) analytics_alarms(); analytics_charts(); analytics_metrics(); + analytics_aclk(); rrdhost_unlock(localhost); @@ -892,6 +879,7 @@ void set_global_environment() analytics_set_data(&analytics_data.netdata_host_cloud_available, "null"); analytics_set_data(&analytics_data.netdata_host_aclk_implementation, "null"); analytics_set_data(&analytics_data.netdata_host_aclk_available, "null"); + analytics_set_data(&analytics_data.netdata_host_aclk_protocol, "null"); analytics_set_data(&analytics_data.netdata_host_agent_claimed, "null"); analytics_set_data(&analytics_data.netdata_host_cloud_enabled, "null"); analytics_set_data(&analytics_data.netdata_config_https_available, "null"); @@ -979,7 +967,7 @@ void send_statistics(const char *action, const char *action_result, const char * sprintf( command_to_run, - "%s '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' ", + "%s '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' '%s' ", as_script, action, action_result, @@ -1013,6 +1001,7 @@ void send_statistics(const char *action, const char *action_result, const char * analytics_data.netdata_config_hosts_available, analytics_data.netdata_host_cloud_available, analytics_data.netdata_host_aclk_available, + analytics_data.netdata_host_aclk_protocol, analytics_data.netdata_host_aclk_implementation, analytics_data.netdata_host_agent_claimed, analytics_data.netdata_host_cloud_enabled, |