]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
swap plugin: Add the `ReportUsage` and `ReportUtilization` config options.
authorFlorian Forster <octo@collectd.org>
Wed, 10 Jan 2024 21:00:03 +0000 (22:00 +0100)
committerFlorian Forster <octo@collectd.org>
Fri, 26 Jan 2024 13:32:14 +0000 (14:32 +0100)
src/collectd.conf.in
src/collectd.conf.pod
src/swap.c

index 18dd82ef6101128112905392ed1a4bba985d76b2..a269306ab9e3fec71155dced44728f77277f268b 100644 (file)
 
 #<Plugin swap>
 #      ReportByDevice false
-#      ReportBytes true
-#      ValuesAbsolute true
-#      ValuesPercentage false
+#      ReportUsage true
+#      ReportUtilization false
 #      ReportIO true
+#      ReportBytes true
 #</Plugin>
 
 #<Plugin sysevent>
index b8b9457a99196bef4f3040a6d1149adb829abb65..d3789285067f743d61f60cbf963d21300fd4985d 100644 (file)
@@ -9334,17 +9334,18 @@ This option is only available if the I<Swap plugin> can read C</proc/swaps>
 =item B<ReportBytes> B<false>|B<true>
 
 When enabled, the I<swap I/O> is reported in bytes. When disabled, the default,
-I<swap I/O> is reported in pages. This option is available under Linux only.
+I<swap I/O> is reported in pages. This option is available under Linux and
+NetBSD only.
 
-=item B<ValuesAbsolute> B<true>|B<false>
+=item B<ReportUsage> B<true>|B<false>
 
 Enables or disables reporting of absolute swap metrics, i.e. number of I<bytes>
 available and used. Defaults to B<true>.
 
-=item B<ValuesPercentage> B<false>|B<true>
+=item B<ReportUtilization> B<false>|B<true>
 
-Enables or disables reporting of relative swap metrics, i.e. I<percent>
-available and free. Defaults to B<false>.
+Enables or disables reporting of relative swap metrics, i.e. the ratio of used
+and free swap space. Defaults to B<false>.
 
 This is useful for deploying I<collectd> in a heterogeneous environment, where
 swap sizes differ and you want to specify generic thresholds or similar.
index 1ac069204420f1461e3baa2a94d9e265f54d1d54..e79f4fbc0988fecdc260e8a0a01b8b3615566353 100644 (file)
@@ -114,8 +114,8 @@ static int pagesize;
 #error "No applicable input method."
 #endif /* HAVE_LIBSTATGRAB */
 
-static bool values_absolute = true;
-static bool values_percentage;
+static bool report_usage = true;
+static bool report_utilization;
 static bool report_io = true;
 
 static char const *const label_device = "system.device";
@@ -152,10 +152,13 @@ static int swap_config(oconfig_item_t *ci) /* {{{ */
               "is not supported on this platform. "
               "The option is going to be ignored.");
 #endif /* SWAP_HAVE_REPORT_BY_DEVICE */
-    else if (strcasecmp("ValuesAbsolute", child->key) == 0)
-      cf_util_get_boolean(child, &values_absolute);
-    else if (strcasecmp("ValuesPercentage", child->key) == 0)
-      cf_util_get_boolean(child, &values_percentage);
+    /* ValuesAbsolute and ValuesPercentage are for collectd 5 compatibility. */
+    else if (strcasecmp("ReportUsage", child->key) == 0 ||
+             strcasecmp("ValuesAbsolute", child->key) == 0)
+      cf_util_get_boolean(child, &report_usage);
+    else if (strcasecmp("ReportUtilization", child->key) == 0 ||
+             strcasecmp("ValuesPercentage", child->key) == 0)
+      cf_util_get_boolean(child, &report_utilization);
     else if (strcasecmp("ReportIO", child->key) == 0)
       cf_util_get_boolean(child, &report_io);
     else
@@ -222,7 +225,7 @@ static void swap_submit_usage3(metric_family_t *fams, char const *device,
 
   bool have_other = (other_name != NULL) && !isnan(other);
 
-  if (values_absolute) {
+  if (report_usage) {
     if (have_other) {
       metric_family_append(fam_usage, label_state, other_name,
                            (value_t){.gauge = other}, &m);
@@ -234,7 +237,7 @@ static void swap_submit_usage3(metric_family_t *fams, char const *device,
                          (value_t){.gauge = free}, &m);
   }
 
-  if (values_percentage) {
+  if (report_utilization) {
     gauge_t total = used + free;
     if (have_other) {
       total += other;