diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-08-12 07:26:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-08-12 07:26:17 +0000 |
commit | 7877a98bd9c00db5e81dd2f8c734cba2bab20be7 (patch) | |
tree | d18b767250f7c7ced9b8abe2ece784ac1fe24d3e /database/sqlite/sqlite_aclk_node.c | |
parent | Releasing debian version 1.35.1-2. (diff) | |
download | netdata-7877a98bd9c00db5e81dd2f8c734cba2bab20be7.tar.xz netdata-7877a98bd9c00db5e81dd2f8c734cba2bab20be7.zip |
Merging upstream version 1.36.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'database/sqlite/sqlite_aclk_node.c')
-rw-r--r-- | database/sqlite/sqlite_aclk_node.c | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/database/sqlite/sqlite_aclk_node.c b/database/sqlite/sqlite_aclk_node.c index 239a24b8c..3d11f83aa 100644 --- a/database/sqlite/sqlite_aclk_node.c +++ b/database/sqlite/sqlite_aclk_node.c @@ -3,23 +3,72 @@ #include "sqlite_functions.h" #include "sqlite_aclk_node.h" -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK #include "../../aclk/aclk_charts_api.h" #endif +#ifdef ENABLE_ACLK +DICTIONARY *collectors_from_charts(RRDHOST *host, DICTIONARY *dict) { + RRDSET *st; + char name[500]; + + rrdhost_rdlock(host); + rrdset_foreach_read(st, host) { + if (rrdset_is_available_for_viewers(st)) { + struct collector_info col = { + .plugin = st->plugin_name ? st->plugin_name : "", + .module = st->module_name ? st->module_name : "" + }; + snprintfz(name, 499, "%s:%s", col.plugin, col.module); + dictionary_set(dict, name, &col, sizeof(struct collector_info)); + } + } + rrdhost_unlock(host); + + return dict; +} +#endif + +void sql_build_node_collectors(struct aclk_database_worker_config *wc) +{ +#ifdef ENABLE_ACLK + if (!wc->host) + return; + + struct update_node_collectors upd_node_collectors; + DICTIONARY *dict = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED); + + upd_node_collectors.node_id = wc->node_id; + upd_node_collectors.claim_id = get_agent_claimid(); + + upd_node_collectors.node_collectors = collectors_from_charts(wc->host, dict); + aclk_update_node_collectors(&upd_node_collectors); + + dictionary_destroy(dict); + freez(upd_node_collectors.claim_id); + + log_access("ACLK RES [%s (%s)]: NODE COLLECTORS SENT", wc->node_id, wc->host->hostname); +#else + UNUSED(wc); +#endif + return; +} + void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd) { UNUSED(cmd); -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK struct update_node_info node_info; - if (!wc->host) + if (!wc->host) { + wc->node_info_send = 1; return; + } rrd_rdlock(); node_info.node_id = wc->node_id; - node_info.claim_id = is_agent_claimed(); + node_info.claim_id = get_agent_claimid(); node_info.machine_guid = wc->host_guid; node_info.child = (wc->host != localhost); node_info.ml_info.ml_capable = ml_capable(localhost); @@ -29,6 +78,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat { .name = "proto", .version = 1, .enabled = 1 }, { .name = "ml", .version = ml_capable(localhost), .enabled = ml_enabled(wc->host) }, { .name = "mc", .version = enable_metric_correlations ? metric_correlations_version : 0, .enabled = enable_metric_correlations }, + { .name = "ctx", .version = 1, .enabled = rrdcontext_enabled}, { .name = NULL, .version = 0, .enabled = 0 } }; node_info.node_instance_capabilities = instance_caps; @@ -61,8 +111,6 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat 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; node_info.data.machine_guid = wc->host_guid; struct capability node_caps[] = { @@ -75,17 +123,16 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat node_info.data.ml_info.ml_capable = host->system_info->ml_capable; node_info.data.ml_info.ml_enabled = host->system_info->ml_enabled; - struct label_index *labels = &host->labels; - netdata_rwlock_rdlock(&labels->labels_rwlock); - node_info.data.host_labels_head = labels->head; + node_info.data.host_labels_ptr = host->host_labels; aclk_update_node_info(&node_info); log_access("ACLK RES [%s (%s)]: NODE INFO SENT for guid [%s] (%s)", wc->node_id, wc->host->hostname, wc->host_guid, wc->host == localhost ? "parent" : "child"); - netdata_rwlock_unlock(&labels->labels_rwlock); rrd_unlock(); freez(node_info.claim_id); freez(host_version); + + wc->node_collectors_send = now_realtime_sec(); #else UNUSED(wc); #endif |