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
Stelios Fragkakis committed
Feb 24, 2022 at 17:09 UTC
e20af33f7cf6757304159ab31eb5b98c58d7d918
1 file changed
+15
-7
database/sqlite/sqlite_aclk_node.c
+15
-7
@@ -27,6 +27,13 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
27
now_realtime_timeval(&node_info.updated_at);
28
29
RRDHOST *host = wc->host;
30
+ char *host_version = NULL;
31
+ if (host != localhost) {
32
+ netdata_mutex_lock(&host->receiver_lock);
33
+ host_version =
34
+ strdupz(host->receiver && host->receiver->program_version ? host->receiver->program_version : "unknown");
35
+ netdata_mutex_unlock(&host->receiver_lock);
36
+ }
37
38
node_info.data.name = host->hostname;
39
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
42
node_info.data.kernel_name = host->system_info->kernel_name;
43
node_info.data.kernel_version = host->system_info->kernel_version;
44
node_info.data.architecture = host->system_info->architecture;
38
- node_info.data.cpus = str2uint32_t(host->system_info->host_cores);
39
- node_info.data.cpu_frequency = host->system_info->host_cpu_freq;
40
- node_info.data.memory = host->system_info->host_ram_total;
41
- node_info.data.disk_space = host->system_info->host_disk_space;
42
- node_info.data.version = VERSION;
45
+ node_info.data.cpus = host->system_info->host_cores ? str2uint32_t(host->system_info->host_cores) : 0;
46
+ node_info.data.cpu_frequency = host->system_info->host_cpu_freq ? host->system_info->host_cpu_freq : "0";
47
+ node_info.data.memory = host->system_info->host_ram_total ? host->system_info->host_ram_total : "0";
48
+ node_info.data.disk_space = host->system_info->host_disk_space ? host->system_info->host_disk_space : "0";
49
+ node_info.data.version = host_version ? host_version : VERSION;
50
node_info.data.release_channel = "nightly";
51
node_info.data.timezone = (char *) host->abbrev_timezone;
45
- node_info.data.virtualization_type = host->system_info->virtualization;
46
- node_info.data.container_type = host->system_info->container;
52
+ node_info.data.virtualization_type = host->system_info->virtualization ? host->system_info->virtualization : "unknown";
53
+ node_info.data.container_type = host->system_info->container ? host->system_info->container : "unknown";
54
node_info.data.custom_info = config_get(CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
55
node_info.data.services = NULL; // char **
56
node_info.data.service_count = 0;
@@ -61,6 +68,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
68
netdata_rwlock_unlock(&labels->labels_rwlock);
69
rrd_unlock();
70
freez(node_info.claim_id);
71
+ freez(host_version);
72
#else
73
UNUSED(wc);
74
#endif