@cryptotaxi247 / netdata-1 / commits / 89a1fd74e

add cpu model to host labels (#18562)

Ilya Mashchenko committed Sep 16, 2024 at 17:57 UTC 89a1fd74eff54f4dcf711f7ca86b40c5373c59b3
2 files changed +10 -2
src/database/rrd.h
+1
@@ -1125,6 +1125,7 @@ struct rrdhost_system_info {
1125 char *host_os_detection;
1126 char *host_cores;
1127 char *host_cpu_freq;
1128 + char *host_cpu_model;
1129 char *host_ram_total;
1130 char *host_disk_space;
1131 char *container_os_name;
src/database/rrdhost.c
+9 -2
@@ -1143,6 +1143,7 @@ void rrdhost_system_info_free(struct rrdhost_system_info *system_info) {
1143 freez(system_info->host_os_detection);
1144 freez(system_info->host_cores);
1145 freez(system_info->host_cpu_freq);
1146 + freez(system_info->host_cpu_model);
1147 freez(system_info->host_ram_total);
1148 freez(system_info->host_disk_space);
1149 freez(system_info->container_os_name);
@@ -1338,6 +1339,7 @@ struct rrdhost_system_info *rrdhost_labels_to_system_info(RRDLABELS *labels) {
1339 rrdlabels_get_value_strdup_or_null(labels, &info->kernel_version, "_kernel_version");
1340 rrdlabels_get_value_strdup_or_null(labels, &info->host_cores, "_system_cores");
1341 rrdlabels_get_value_strdup_or_null(labels, &info->host_cpu_freq, "_system_cpu_freq");
1342 + rrdlabels_get_value_strdup_or_null(labels, &info->host_cpu_model, "_system_cpu_model");
1343 rrdlabels_get_value_strdup_or_null(labels, &info->host_ram_total, "_system_ram_total");
1344 rrdlabels_get_value_strdup_or_null(labels, &info->host_disk_space, "_system_disk_space");
1345 rrdlabels_get_value_strdup_or_null(labels, &info->architecture, "_architecture");
@@ -1380,6 +1382,9 @@ static void rrdhost_load_auto_labels(void) {
1382 if (localhost->system_info->host_cpu_freq)
1383 rrdlabels_add(labels, "_system_cpu_freq", localhost->system_info->host_cpu_freq, RRDLABEL_SRC_AUTO);
1384
1385 + if (localhost->system_info->host_cpu_model)
1386 + rrdlabels_add(labels, "_system_cpu_model", localhost->system_info->host_cpu_model, RRDLABEL_SRC_AUTO);
1387 +
1388 if (localhost->system_info->host_ram_total)
1389 rrdlabels_add(labels, "_system_ram_total", localhost->system_info->host_ram_total, RRDLABEL_SRC_AUTO);
1390
@@ -1604,6 +1609,10 @@ int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, ch
1609 freez(system_info->host_cpu_freq);
1610 system_info->host_cpu_freq = strdupz(value);
1611 }
1612 + else if (!strcmp(name, "NETDATA_SYSTEM_CPU_MODEL")){
1613 + freez(system_info->host_cpu_model);
1614 + system_info->host_cpu_model = strdupz(value);
1615 + }
1616 else if(!strcmp(name, "NETDATA_SYSTEM_TOTAL_RAM")){
1617 freez(system_info->host_ram_total);
1618 system_info->host_ram_total = strdupz(value);
@@ -1642,8 +1651,6 @@ int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, ch
1651 }
1652 else if (!strcmp(name, "NETDATA_SYSTEM_CPU_VENDOR"))
1653 return res;
1645 - else if (!strcmp(name, "NETDATA_SYSTEM_CPU_MODEL"))
1646 - return res;
1654 else if (!strcmp(name, "NETDATA_SYSTEM_CPU_DETECTION"))
1655 return res;
1656 else if (!strcmp(name, "NETDATA_SYSTEM_RAM_DETECTION"))