summaryrefslogtreecommitdiffstats
path: root/database
diff options
context:
space:
mode:
Diffstat (limited to 'database')
-rw-r--r--database/rrd.h4
-rw-r--r--database/rrdcalc.c2
-rw-r--r--database/rrdhost.c33
-rw-r--r--database/rrdlabels.c2
4 files changed, 34 insertions, 7 deletions
diff --git a/database/rrd.h b/database/rrd.h
index 60be22a677..d138442124 100644
--- a/database/rrd.h
+++ b/database/rrd.h
@@ -279,7 +279,7 @@ void rrdlabels_destroy(DICTIONARY *labels_dict);
void rrdlabels_add(DICTIONARY *dict, const char *name, const char *value, RRDLABEL_SRC ls);
void rrdlabels_add_pair(DICTIONARY *dict, const char *string, RRDLABEL_SRC ls);
void rrdlabels_get_value_to_buffer_or_null(DICTIONARY *labels, BUFFER *wb, const char *key, const char *quote, const char *null);
-void rrdlabels_get_value_to_char_or_null(DICTIONARY *labels, char **value, const char *key);
+void rrdlabels_get_value_strdup_or_null(DICTIONARY *labels, char **value, const char *key);
void rrdlabels_flush(DICTIONARY *labels_dict);
void rrdlabels_unmark_all(DICTIONARY *labels);
@@ -961,6 +961,8 @@ struct rrdhost_system_info {
int mc_version;
};
+struct rrdhost_system_info *rrdhost_labels_to_system_info(DICTIONARY *labels);
+
struct rrdhost {
char machine_guid[GUID_LEN + 1]; // the unique ID of this host
diff --git a/database/rrdcalc.c b/database/rrdcalc.c
index 1bfd502848..e25a22805a 100644
--- a/database/rrdcalc.c
+++ b/database/rrdcalc.c
@@ -100,7 +100,7 @@ static STRING *rrdcalc_replace_variables_with_rrdset_labels(const char *line, RR
label_val[i - RRDCALC_VAR_LABEL_LEN - 1] = '\0';
if(likely(rc->rrdset && rc->rrdset->rrdlabels)) {
- rrdlabels_get_value_to_char_or_null(rc->rrdset->rrdlabels, &lbl_value, label_val);
+ rrdlabels_get_value_strdup_or_null(rc->rrdset->rrdlabels, &lbl_value, label_val);
if (lbl_value) {
char *buf = find_and_replace(temp, var, lbl_value, m);
freez(temp);
diff --git a/database/rrdhost.c b/database/rrdhost.c
index f9a657a248..ee7503c4fc 100644
--- a/database/rrdhost.c
+++ b/database/rrdhost.c
@@ -1279,6 +1279,33 @@ void rrdhost_save_charts(RRDHOST *host) {
rrdset_foreach_done(st);
}
+struct rrdhost_system_info *rrdhost_labels_to_system_info(DICTIONARY *labels) {
+ struct rrdhost_system_info *info = callocz(1, sizeof(struct rrdhost_system_info));
+ info->hops = 1;
+
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->cloud_provider_type, "_cloud_provider_type");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->cloud_instance_type, "_cloud_instance_type");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->cloud_instance_region, "_cloud_instance_region");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->host_os_name, "_os_name");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->host_os_version, "_os_version");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->kernel_version, "_kernel_version");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->host_cores, "_system_cores");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->host_cpu_freq, "_system_cpu_freq");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->host_ram_total, "_system_ram_total");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->host_disk_space, "_system_disk_space");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->architecture, "_architecture");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->virtualization, "_virtualization");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->container, "_container");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->container_detection, "_container_detection");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->virt_detection, "_virt_detection");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->is_k8s_node, "_is_k8s_node");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->install_type, "_install_type");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->prebuilt_arch, "_prebuilt_arch");
+ rrdlabels_get_value_strdup_or_null(labels, &localhost->system_info->prebuilt_dist, "_prebuilt_dist");
+
+ return info;
+}
+
static void rrdhost_load_auto_labels(void) {
DICTIONARY *labels = localhost->rrdlabels;
@@ -1289,8 +1316,7 @@ static void rrdhost_load_auto_labels(void) {
rrdlabels_add(labels, "_cloud_instance_type", localhost->system_info->cloud_instance_type, RRDLABEL_SRC_AUTO);
if (localhost->system_info->cloud_instance_region)
- rrdlabels_add(
- labels, "_cloud_instance_region", localhost->system_info->cloud_instance_region, RRDLABEL_SRC_AUTO);
+ rrdlabels_add(labels, "_cloud_instance_region", localhost->system_info->cloud_instance_region, RRDLABEL_SRC_AUTO);
if (localhost->system_info->host_os_name)
rrdlabels_add(labels, "_os_name", localhost->system_info->host_os_name, RRDLABEL_SRC_AUTO);
@@ -1354,8 +1380,7 @@ void rrdhost_set_is_parent_label(int count) {
DICTIONARY *labels = localhost->rrdlabels;
if (count == 0 || count == 1) {
- rrdlabels_add(
- labels, "_is_parent", (count) ? "true" : "false", RRDLABEL_SRC_AUTO);
+ rrdlabels_add(labels, "_is_parent", (count) ? "true" : "false", RRDLABEL_SRC_AUTO);
//queue a node info
#ifdef ENABLE_ACLK
diff --git a/database/rrdlabels.c b/database/rrdlabels.c
index 4a9a6dae6a..38ca9e6159 100644
--- a/database/rrdlabels.c
+++ b/database/rrdlabels.c
@@ -654,7 +654,7 @@ void rrdlabels_get_value_to_buffer_or_null(DICTIONARY *labels, BUFFER *wb, const
// ----------------------------------------------------------------------------
// rrdlabels_get_value_to_char_or_null()
-void rrdlabels_get_value_to_char_or_null(DICTIONARY *labels, char **value, const char *key) {
+void rrdlabels_get_value_strdup_or_null(DICTIONARY *labels, char **value, const char *key) {
const DICTIONARY_ITEM *acquired_item = dictionary_get_and_acquire_item(labels, key);
RRDLABEL *lb = dictionary_acquired_item_value(acquired_item);