Browse Source

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 3 years ago
parent
commit
e20af33f7c
1 changed files with 15 additions and 7 deletions
  1. 15 7
      database/sqlite/sqlite_aclk_node.c

+ 15 - 7
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