From: Florian Forster Date: Wed, 27 Dec 2023 08:44:43 +0000 (+0100) Subject: df plugin: Report filesystem mode (ro/rw). X-Git-Tag: 6.0.0-rc0~8^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=497551283f153164df12e35136c46d5221944e65;p=thirdparty%2Fcollectd.git df plugin: Report filesystem mode (ro/rw). --- diff --git a/src/df.c b/src/df.c index 79b26847b..12c8b1ebd 100644 --- a/src/df.c +++ b/src/df.c @@ -47,10 +47,14 @@ #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);