diff options
author | Andrew Moss <1043609+amoss@users.noreply.github.com> | 2020-01-21 16:08:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-21 16:08:59 +0100 |
commit | 49f6950820f083956ddc2c9327eeae4e9ef0d5ed (patch) | |
tree | c551bb219e2503c55e3b4e668408d4bff9ac99d8 /database/rrdhost.c | |
parent | 434c9ba6e17aa80548e1fccbcadccaa1572d76eb (diff) |
Issue 7488 docker labels (#7770)
Improve the metadata detection for containers. The system_info structure has been updated to hold separate copies of OS_NAME, OS_ID, OS_ID_LIKE, OS_VERSION, OS_VERSION_ID and OS_DETECTION for both the container environment and the host. This new information is communicated through the /api/v1/info endpoint. For the streaming interface a partial copy of the info is carried until the stream protocol is upgraded. The anonymous_statistics script has been updated to carry the new data to Google Analytics. Some minor improvements have been made to OS-X / FreeBSD detection, and the detection of virtualization. The docs have been updated to explain how to pass the host environment to the docker container running Netdata.
Diffstat (limited to 'database/rrdhost.c')
-rw-r--r-- | database/rrdhost.c | 96 |
1 files changed, 67 insertions, 29 deletions
diff --git a/database/rrdhost.c b/database/rrdhost.c index 5a4b195807..48bec95a21 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -563,12 +563,18 @@ void rrdhost_system_info_free(struct rrdhost_system_info *system_info) { info("SYSTEM_INFO: free %p", system_info); if(likely(system_info)) { - freez(system_info->os_name); - freez(system_info->os_id); - freez(system_info->os_id_like); - freez(system_info->os_version); - freez(system_info->os_version_id); - freez(system_info->os_detection); + freez(system_info->host_os_name); + freez(system_info->host_os_id); + freez(system_info->host_os_id_like); + freez(system_info->host_os_version); + freez(system_info->host_os_version_id); + freez(system_info->host_os_detection); + freez(system_info->container_os_name); + freez(system_info->container_os_id); + freez(system_info->container_os_id_like); + freez(system_info->container_os_version); + freez(system_info->container_os_version_id); + freez(system_info->container_os_detection); freez(system_info->kernel_name); freez(system_info->kernel_version); freez(system_info->architecture); @@ -762,13 +768,13 @@ struct label *load_auto_labels() { struct label *label_list = NULL; - if (localhost->system_info->os_name) + if (localhost->system_info->host_os_name) label_list = - add_label_to_list(label_list, "_os_name", localhost->system_info->os_name, LABEL_SOURCE_AUTO); + add_label_to_list(label_list, "_os_name", localhost->system_info->host_os_name, LABEL_SOURCE_AUTO); - if (localhost->system_info->os_version) + if (localhost->system_info->host_os_version) label_list = - add_label_to_list(label_list, "_os_version", localhost->system_info->os_version, LABEL_SOURCE_AUTO); + add_label_to_list(label_list, "_os_version", localhost->system_info->host_os_version, LABEL_SOURCE_AUTO); if (localhost->system_info->kernel_version) label_list = @@ -782,9 +788,17 @@ struct label *load_auto_labels() label_list = add_label_to_list(label_list, "_virtualization", localhost->system_info->virtualization, LABEL_SOURCE_AUTO); + if (localhost->system_info->container) + label_list = + add_label_to_list(label_list, "_container", localhost->system_info->container, LABEL_SOURCE_AUTO); + + if (localhost->system_info->container_detection) + label_list = + add_label_to_list(label_list, "_container_detection", localhost->system_info->container_detection, LABEL_SOURCE_AUTO); + if (localhost->system_info->virt_detection) label_list = - add_label_to_list(label_list, "_container", localhost->system_info->virt_detection, LABEL_SOURCE_AUTO); + add_label_to_list(label_list, "_virt_detection", localhost->system_info->virt_detection, LABEL_SOURCE_AUTO); label_list = add_label_to_list( label_list, "_is_master", (localhost->next || configured_as_master()) ? "true" : "false", LABEL_SOURCE_AUTO); @@ -1115,29 +1129,53 @@ restart_after_removal: int rrdhost_set_system_info_variable(struct rrdhost_system_info *system_info, char *name, char *value) { int res = 0; - if(!strcmp(name, "NETDATA_SYSTEM_OS_NAME")){ - freez(system_info->os_name); - system_info->os_name = strdupz(value); + if(!strcmp(name, "NETDATA_CONTAINER_OS_NAME")){ + freez(system_info->container_os_name); + system_info->container_os_name = strdupz(value); + } + else if(!strcmp(name, "NETDATA_CONTAINER_OS_ID")){ + freez(system_info->container_os_id); + system_info->container_os_id = strdupz(value); + } + else if(!strcmp(name, "NETDATA_CONTAINER_OS_ID_LIKE")){ + freez(system_info->container_os_id_like); + system_info->container_os_id_like = strdupz(value); + } + else if(!strcmp(name, "NETDATA_CONTAINER_OS_VERSION")){ + freez(system_info->container_os_version); + system_info->container_os_version = strdupz(value); + } + else if(!strcmp(name, "NETDATA_CONTAINER_OS_VERSION_ID")){ + freez(system_info->container_os_version_id); + system_info->container_os_version_id = strdupz(value); + } + else if(!strcmp(name, "NETDATA_CONTAINER_OS_DETECTION")){ + freez(system_info->host_os_detection); + system_info->host_os_detection = strdupz(value); + } + else if(!strcmp(name, "NETDATA_HOST_OS_NAME")){ + freez(system_info->host_os_name); + system_info->host_os_name = strdupz(value); } - else if(!strcmp(name, "NETDATA_SYSTEM_OS_ID")){ - freez(system_info->os_id); - system_info->os_id = strdupz(value); + else if(!strcmp(name, "NETDATA_HOST_OS_ID")){ + freez(system_info->host_os_id); + system_info->host_os_id = strdupz(value); } - else if(!strcmp(name, "NETDATA_SYSTEM_OS_ID_LIKE")){ - freez(system_info->os_id_like); - system_info->os_id_like = strdupz(value); + else if(!strcmp(name, "NETDATA_HOST_OS_ID_LIKE")){ + freez(system_info->host_os_id_like); + system_info->host_os_id_like = strdupz(value); } - else if(!strcmp(name, "NETDATA_SYSTEM_OS_VERSION")){ - freez(system_info->os_version); - system_info->os_version = strdupz(value); + else if(!strcmp(name, "NETDATA_HOST_OS_VERSION")){ + freez(system_info->host_os_version); + system_info->host_os_version = strdupz(value); } - else if(!strcmp(name, "NETDATA_SYSTEM_OS_VERSION_ID")){ - freez(system_info->os_version_id); - system_info->os_version_id = strdupz(value); + else if(!strcmp(name, "NETDATA_HOST_OS_VERSION_ID")){ + freez(system_info->host_os_version_id); + system_info->host_os_version_id = strdupz(value); } - else if(!strcmp(name, "NETDATA_SYSTEM_OS_DETECTION")){ - freez(system_info->os_detection); - system_info->os_detection = strdupz(value); + else if(!strcmp(name, "NETDATA_HOST_OS_DETECTION")){ + freez(system_info->host_os_detection); + system_info->host_os_detection = strdupz(value); } else if(!strcmp(name, "NETDATA_SYSTEM_KERNEL_NAME")){ freez(system_info->kernel_name); |