]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
df plugin: Add the `ReportUsage` and `ReportUtilization` config options. 4218/head
authorFlorian Forster <octo@collectd.org>
Wed, 10 Jan 2024 21:12:31 +0000 (22:12 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 15 Jan 2024 19:26:04 +0000 (20:26 +0100)
src/collectd.conf.in
src/collectd.conf.pod
src/df.c

index 8334c89e145a4e52b1cd194a091bbba8cf256516..791236d04143252574636c701bda5e356e60ad9d 100644 (file)
 #      MountPoint "/home"
 #      FSType "ext3"
 #      IgnoreSelected false
+#
 #      LogOnce false
-#      ReportByDevice false
 #      ReportInodes false
-#      ValuesAbsolute true
-#      ValuesPercentage false
+#      ReportUsage true
+#      ReportUtilization false
 #</Plugin>
 
 #<Plugin disk>
index bc6c2b87f5d4eef5df703947623c54a70e12dc02..2cf343c5185d41f0bdf85970f331d287c69121c3 100644 (file)
@@ -2945,14 +2945,14 @@ Enable this option if inodes are a scarce resource for you, usually because
 many small files are stored on the disk. This is a usual scenario for mail
 transfer agents and web caches.
 
-=item B<ValuesAbsolute> B<true>|B<false>
+=item B<ReportUsage> B<true>|B<false>
 
-Enables or disables reporting of free and used disk space in 1K-blocks.
+Enables or disables reporting of free and used disk space in bytes.
 Defaults to B<true>.
 
-=item B<ValuesPercentage> B<false>|B<true>
+=item B<ReportUtilization> B<false>|B<true>
 
-Enables or disables reporting of free and used disk space in percentage.
+Enables or disables reporting of free and used disk space as ratio.
 Defaults to B<false>.
 
 This is useful for deploying I<collectd> on the cloud, where machines with
index c820a63cead8974d977609b988e3533c1ded70c2..fb81a1bb8635be29f569893dc4105ce1a09efff0 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -71,8 +71,8 @@ static ignorelist_t *il_fstype;
 static ignorelist_t *il_errors;
 
 static bool report_inodes;
-static bool values_absolute = true;
-static bool values_percentage;
+static bool report_usage = true;
+static bool report_utilization;
 static bool log_once;
 
 static int df_init(void) {
@@ -124,18 +124,20 @@ static int df_config(const char *key, const char *value) {
       report_inodes = false;
 
     return 0;
-  } else if (strcasecmp(key, "ValuesAbsolute") == 0) {
+  } else if (strcasecmp(key, "ReportUsage") == 0 ||
+             strcasecmp(key, "ValuesAbsolute") == 0) {
     if (IS_TRUE(value))
-      values_absolute = true;
+      report_usage = true;
     else
-      values_absolute = false;
+      report_usage = false;
 
     return 0;
-  } else if (strcasecmp(key, "ValuesPercentage") == 0) {
+  } else if (strcasecmp(key, "ReportUtilization") == 0 ||
+             strcasecmp(key, "ValuesPercentage") == 0) {
     if (IS_TRUE(value))
-      values_percentage = true;
+      report_utilization = true;
     else
-      values_percentage = false;
+      report_utilization = false;
 
     return 0;
   } else if (strcasecmp(key, "LogOnce") == 0) {
@@ -250,7 +252,7 @@ static int df_read(void) {
     metric_label_set(&m, mountpoint_label, mnt_ptr->dir);
     metric_label_set(&m, type_label, mnt_ptr->type);
 
-    if (values_absolute) {
+    if (report_usage) {
       metric_family_append(&fam_usage, state_label, state_used,
                            (value_t){.gauge = blk_used * blocksize}, &m);
 
@@ -261,7 +263,7 @@ static int df_read(void) {
                            (value_t){.gauge = blk_reserved * blocksize}, &m);
     }
 
-    if (values_percentage) {
+    if (report_utilization) {
       assert(statbuf.f_blocks != 0); // checked above
       gauge_t f = 1.0 / (gauge_t)statbuf.f_blocks;
 
@@ -287,7 +289,7 @@ static int df_read(void) {
       gauge_t inode_reserved = (gauge_t)(statbuf.f_ffree - statbuf.f_favail);
       gauge_t inode_used = (gauge_t)(statbuf.f_files - statbuf.f_ffree);
 
-      if (values_percentage) {
+      if (report_utilization) {
         if (statbuf.f_files > 0) {
           gauge_t f = 1.0 / (gauge_t)statbuf.f_files;
 
@@ -306,7 +308,7 @@ static int df_read(void) {
           break;
         }
       }
-      if (values_absolute) {
+      if (report_usage) {
         metric_family_append(&fam_inode_usage, state_label, state_used,
                              (value_t){.gauge = inode_used}, &m);