From 497551283f153164df12e35136c46d5221944e65 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 27 Dec 2023 09:44:43 +0100 Subject: [PATCH] df plugin: Report filesystem mode (ro/rw). --- src/df.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.47.2