From 67285dfcc5218aee99ad5b96d241372e16a56e5c Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 4 Jan 2024 07:23:28 +0100 Subject: [PATCH] memory plugin: Rename `ValuesAbsolute` to `ReportUsage`. --- src/collectd.conf.in | 2 +- src/collectd.conf.pod | 2 +- src/memory.c | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index d0d1a90c7..4135898f4 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -1056,7 +1056,7 @@ # # -# ValuesAbsolute true +# ReportUsage true # ValuesPercentage false # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 761b00f30..6870342c1 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -5269,7 +5269,7 @@ The I provides the following configuration options: =over 4 -=item B B|B +=item B B|B Enables or disables reporting of physical memory usage in absolute numbers, i.e. bytes. Defaults to B. diff --git a/src/memory.c b/src/memory.c index e2ee21b6e..081d0a31f 100644 --- a/src/memory.c +++ b/src/memory.c @@ -149,15 +149,16 @@ static int pagesize; #include #endif -static bool values_absolute = true; +static bool report_usage = true; static bool values_percentage; static int memory_config(oconfig_item_t *ci) /* {{{ */ { for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; - if (strcasecmp("ValuesAbsolute", child->key) == 0) - cf_util_get_boolean(child, &values_absolute); + if (strcasecmp("ReportUsage", child->key) == 0 || + strcasecmp("ValuesAbsolute", child->key) == 0) + cf_util_get_boolean(child, &report_usage); else if (strcasecmp("ValuesPercentage", child->key) == 0) cf_util_get_boolean(child, &values_percentage); else @@ -168,7 +169,7 @@ static int memory_config(oconfig_item_t *ci) /* {{{ */ } /* }}} int memory_config */ static int memory_dispatch(gauge_t values[COLLECTD_MEMORY_TYPE_MAX]) { - metric_family_t fam_absolute = { + metric_family_t fam_usage = { .name = "system.memory.usage", .help = "Reports memory in use by state", .unit = "By", @@ -183,22 +184,22 @@ static int memory_dispatch(gauge_t values[COLLECTD_MEMORY_TYPE_MAX]) { total += values[i]; - if (values_absolute) { - metric_family_append(&fam_absolute, label_state, memory_type_names[i], + if (report_usage) { + metric_family_append(&fam_usage, label_state, memory_type_names[i], (value_t){.gauge = values[i]}, NULL); } } int ret = 0; - if (values_absolute) { - int status = plugin_dispatch_metric_family(&fam_absolute); + if (report_usage) { + int status = plugin_dispatch_metric_family(&fam_usage); if (status != 0) { ERROR("memory plugin: plugin_dispatch_metric_family failed: %s", STRERROR(status)); } ret = status; } - metric_family_metric_reset(&fam_absolute); + metric_family_metric_reset(&fam_usage); if (!values_percentage) { return ret; -- 2.47.2