summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-02-24 17:09:14 +0200
committerGitHub <noreply@github.com>2022-02-24 17:09:14 +0200
commite20af33f7cf6757304159ab31eb5b98c58d7d918 (patch)
tree1883d5bf3149932dd0f415a28fb7458b815eef16 /database
parent69ea17d6ec534e1ed796a92fd042bd76a3ca9215 (diff)
Fix node information send to the cloud for older agent versions (#12223)
* Find the correct host netdata version from streaming info if not localhost * Handle old netdata versions that do not supply information during the streaming connection * Send unknown agent version if child is not connected
Diffstat (limited to 'database')
-rw-r--r--database/sqlite/sqlite_aclk_node.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/database/sqlite/sqlite_aclk_node.c b/database/sqlite/sqlite_aclk_node.c
index 9464c41f27..f173781c98 100644
--- a/database/sqlite/sqlite_aclk_node.c
+++ b/database/sqlite/sqlite_aclk_node.c
@@ -27,6 +27,13 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
now_realtime_timeval(&node_info.updated_at);
RRDHOST *host = wc->host;
+ char *host_version = NULL;
+ if (host != localhost) {
+ netdata_mutex_lock(&host->receiver_lock);
+ host_version =
+ strdupz(host->receiver && host->receiver->program_version ? host->receiver->program_version : "unknown");
+ netdata_mutex_unlock(&host->receiver_lock);
+ }
node_info.data.name = host->hostname;
node_info.data.os = (char *) host->os;
@@ -35,15 +42,15 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
node_info.data.kernel_name = host->system_info->kernel_name;
node_info.data.kernel_version = host->system_info->kernel_version;
node_info.data.architecture = host->system_info->architecture;
- node_info.data.cpus = str2uint32_t(host->system_info->host_cores);
- node_info.data.cpu_frequency = host->system_info->host_cpu_freq;
- node_info.data.memory = host->system_info->host_ram_total;
- node_info.data.disk_space = host->system_info->host_disk_space;
- node_info.data.version = VERSION;
+ node_info.data.cpus = host->system_info->host_cores ? str2uint32_t(host->system_info->host_cores) : 0;
+ node_info.data.cpu_frequency = host->system_info->host_cpu_freq ? host->system_info->host_cpu_freq : "0";
+ node_info.data.memory = host->system_info->host_ram_total ? host->system_info->host_ram_total : "0";
+ node_info.data.disk_space = host->system_info->host_disk_space ? host->system_info->host_disk_space : "0";
+ node_info.data.version = host_version ? host_version : VERSION;
node_info.data.release_channel = "nightly";
node_info.data.timezone = (char *) host->abbrev_timezone;
- node_info.data.virtualization_type = host->system_info->virtualization;
- node_info.data.container_type = host->system_info->container;
+ node_info.data.virtualization_type = host->system_info->virtualization ? host->system_info->virtualization : "unknown";
+ node_info.data.container_type = host->system_info->container ? host->system_info->container : "unknown";
node_info.data.custom_info = config_get(CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
node_info.data.services = NULL; // char **
node_info.data.service_count = 0;
@@ -61,6 +68,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
netdata_rwlock_unlock(&labels->labels_rwlock);
rrd_unlock();
freez(node_info.claim_id);
+ freez(host_version);
#else
UNUSED(wc);
#endif