diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2020-02-07 20:14:47 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 12:14:47 -0800 |
commit | ee55155912c17139a3a0ab2815f15651e63e5a9c (patch) | |
tree | 3cbaf6c35e0ac9dba8023a9db9b2979c266992d5 /database | |
parent | 57055c9ac18e70a812aec4230219e928405cbb26 (diff) |
Update `api/v1/info ` (#7862)
* update_info: New variables
This commit creates inside script and it reads them to Netdata
* update_info: API
This commit changes the web api response
* update_info: Disk space
This commit brings the disk space to info and renames the environment variables inside Netdata
* update_info: Rename variable
This commit renames the environment variable
* update_info: Rename response variable
This commit renames a response variable
* update_info: Labels
This commit creates the missing labels
* update_info: test before free
* update_info: Doc function
This commit brings docummentation to the functions to give instructions to developer
* update_info: Fix info message
This commit removes some info messages from the error.log
* update_info: Remove unecessary ifs, considering free manual
Diffstat (limited to 'database')
-rw-r--r-- | database/rrd.h | 4 | ||||
-rw-r--r-- | database/rrdhost.c | 48 |
2 files changed, 51 insertions, 1 deletions
diff --git a/database/rrd.h b/database/rrd.h index f569a09d53..62dbac39e2 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -624,6 +624,10 @@ struct rrdhost_system_info { char *host_os_version; char *host_os_version_id; char *host_os_detection; + char *host_cores; + char *host_cpu_freq; + char *host_ram_total; + char *host_disk_space; char *container_os_name; char *container_os_id; char *container_os_id_like; diff --git a/database/rrdhost.c b/database/rrdhost.c index 6a11fc9020..1b5e460d02 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -573,6 +573,10 @@ void rrdhost_system_info_free(struct rrdhost_system_info *system_info) { freez(system_info->host_os_version); freez(system_info->host_os_version_id); freez(system_info->host_os_detection); + freez(system_info->host_cores); + freez(system_info->host_cpu_freq); + freez(system_info->host_ram_total); + freez(system_info->host_disk_space); freez(system_info->container_os_name); freez(system_info->container_os_id); freez(system_info->container_os_id_like); @@ -786,6 +790,22 @@ struct label *load_auto_labels() label_list = add_label_to_list(label_list, "_kernel_version", localhost->system_info->kernel_version, LABEL_SOURCE_AUTO); + if (localhost->system_info->host_cores) + label_list = + add_label_to_list(label_list, "_system_cores", localhost->system_info->host_cores, LABEL_SOURCE_AUTO); + + if (localhost->system_info->host_cpu_freq) + label_list = + add_label_to_list(label_list, "_system_cpu_freq", localhost->system_info->host_cpu_freq, LABEL_SOURCE_AUTO); + + if (localhost->system_info->host_ram_total) + label_list = + add_label_to_list(label_list, "_system_ram_total", localhost->system_info->host_ram_total, LABEL_SOURCE_AUTO); + + if (localhost->system_info->host_disk_space) + label_list = + add_label_to_list(label_list, "_system_disk_space", localhost->system_info->host_disk_space, LABEL_SOURCE_AUTO); + if (localhost->system_info->architecture) label_list = add_label_to_list(label_list, "_architecture", localhost->system_info->architecture, LABEL_SOURCE_AUTO); @@ -1308,7 +1328,7 @@ restart_after_removal: // ---------------------------------------------------------------------------- // RRDHOST - set system info from environment variables - +// system_info fields must be heap allocated or NULL int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, char *name, char *value) { int res = 0; @@ -1366,6 +1386,22 @@ int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, ch freez(system_info->kernel_name); system_info->kernel_name = strdupz(value); } + else if(!strcmp(name, "NETDATA_SYSTEM_CPU_LOGICAL_CPU_COUNT")){ + freez(system_info->host_cores); + system_info->host_cores = strdupz(value); + } + else if(!strcmp(name, "NETDATA_SYSTEM_CPU_FREQ")){ + freez(system_info->host_cpu_freq); + system_info->host_cpu_freq = strdupz(value); + } + else if(!strcmp(name, "NETDATA_SYSTEM_TOTAL_RAM")){ + freez(system_info->host_ram_total); + system_info->host_ram_total = strdupz(value); + } + else if(!strcmp(name, "NETDATA_SYSTEM_TOTAL_DISK_SIZE")){ + freez(system_info->host_disk_space); + system_info->host_disk_space = strdupz(value); + } else if(!strcmp(name, "NETDATA_SYSTEM_KERNEL_VERSION")){ freez(system_info->kernel_version); system_info->kernel_version = strdupz(value); @@ -1390,6 +1426,16 @@ int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, ch freez(system_info->container_detection); system_info->container_detection = strdupz(value); } + else if (!strcmp(name, "NETDATA_SYSTEM_CPU_VENDOR")) + return res; + else if (!strcmp(name, "NETDATA_SYSTEM_CPU_MODEL")) + return res; + else if (!strcmp(name, "NETDATA_SYSTEM_CPU_DETECTION")) + return res; + else if (!strcmp(name, "NETDATA_SYSTEM_RAM_DETECTION")) + return res; + else if (!strcmp(name, "NETDATA_SYSTEM_DISK_DETECTION")) + return res; else { res = 1; } |