Open benschweizer opened 4 years ago
I believe the source of this data is /proc/self/mountinfo
, can you add the contents of it?
# cat mountinfo | grep backup
117 25 0:41 / /backup rw,relatime shared:65 - btrfs /dev/mapper/vg1-backup ro,compress=lzo,space_cache,subvolid=5,subvol=/
119 25 0:42 / /nobackup rw,relatime shared:69 - btrfs /dev/mapper/vg0-nobackup rw,compress=lzo,space_cache,subvolid=5,subvol=/
I see a difference in field 11 but not in field 6, but the kernel docs are not very elaborate there: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
(1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)
(6) mount options: per mount options
(11) super options: per super block options
So it seems this is mount options vs super block options. In man proc
it
references man 2 mount
for info on super block options.
From Linux 2.4 onward, some of the above flags are settable on a per- mount basis, while others apply to the superblock of the mounted filesystem, meaning that all mounts of the same filesystem share those flags. (Previously, all of the flags were per-superblock.)
Since Linux 2.6.16, MS_RDONLY can be set or cleared on a per-mount- point basis as well as on the underlying filesystem superblock. The mounted filesystem will be writable only if neither the filesystem nor the mountpoint are flagged as read-only.
So it seems to me that we should report mode=rw
only if both the block and superblock are rw
.
We may want this implemented in gopsutil, I'll open an issue there to discuss how best to handle this.
Just upgraded to recent version and no longer getting correct metrics about filesystems remounted as read-only due to issues with disks. Gopsutil upstream doesn't seem terribly responsive regarding this.
Maybe the title of this issue can be changed because this is not a special btrfs-problem.
Can someone create a pull request for gopsutil exposing the superblock options? I'm not sure if they will accept the change but it would be helpful to provide them something concrete for review.
any updates on this? I am using this to monitor the ro-mounts after mount-problems, which is not working at the moment.
If somebody needs a workaround: The following check just counts the number of read-only mounts:
[[inputs.exec]]
timeout = "5s"
data_format = "influx"
commands = ["bash -c '/bin/echo my_checks ro_mounts=$(mount | grep -c ro,)'"]
I have pinged upstream on the above PR, in hopes of getting a clear answer on whether they will take it or not.
Relevant telegraf.conf:
System info:
Steps to reproduce:
Expected behavior:
the disk plugin should reports the true value from /proc/mounts
Actual behavior:
the disk plugin relies on https://github.com/shirou/gopsutil/blob/master/disk/disk_linux.go which relies probably on /etc/mount or some other wrong data
Additional info: