]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
df plugin: Report filesystem mode (ro/rw).
authorFlorian Forster <octo@collectd.org>
Wed, 27 Dec 2023 08:44:43 +0000 (09:44 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 15 Jan 2024 19:26:04 +0000 (20:26 +0100)
src/df.c

index 79b26847b45107188dcc32ac5f2e8e6489b33fdd..12c8b1ebd2ee79049a5f300f9cd7a1083cbca5a1 100644 (file)
--- a/src/df.c
+++ b/src/df.c
 #endif
 
 static char const *const device_label = "system.device";
+static char const *const mode_label = "system.filesystem.mode";
 static char const *const mountpoint_label = "system.filesystem.mountpoint";
 static char const *const state_label = "system.filesystem.state";
 static char const *const type_label = "system.filesystem.type";
 
+static char const *const mode_ro = "ro";
+static char const *const mode_rw = "rw";
+
 static const char *config_keys[] = {
     "Device",         "MountPoint",       "FSType",
     "IgnoreSelected", "ReportByDevice",   "ReportInodes",
@@ -234,8 +238,11 @@ static int df_read(void) {
     gauge_t blk_reserved = (gauge_t)(statbuf.f_bfree - statbuf.f_bavail);
     gauge_t blk_used = (gauge_t)(statbuf.f_blocks - statbuf.f_bfree);
 
+    bool read_only = (statbuf.f_flag & ST_RDONLY) != 0;
+
     metric_t m = {0};
     metric_label_set(&m, device_label, dev);
+    metric_label_set(&m, mode_label, read_only ? mode_ro : mode_rw);
     metric_label_set(&m, mountpoint_label, mnt_ptr->dir);
     metric_label_set(&m, type_label, mnt_ptr->type);