Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric "node_filesystem_readonly" does not include super options when calculating #3157

Open
duanchao2035 opened this issue Oct 17, 2024 · 1 comment

Comments

@duanchao2035
Copy link

duanchao2035 commented Oct 17, 2024

Question description

Hello, I would like to ask a question. When using node-exporter for metric collection, I have noticed an inconsistency in the behavior of the metric "node_filesystem_readonly" across different versions. In version 1.6.1, the value is obtained through /proc/1/mounts' options, while in the latest version, it is obtained through /proc/1/mountinfo. When I execute the following commands on the host with a read-only root partition:

cat /proc/1/mountinfo | grep /dev/md127
44 0 9:127 / / rw,relatime shared:1 - ext4 /dev/md127 ro
cat /proc/1/mounts | grep md127
/dev/md127 / ext4 ro,relatime 0 0

As per the code logic, in version 1.6.1, the "ro" value is 1, whereas in the latest version, it is 0 (the options value in the new version's file does not include "ro", but the super options include it). I would like to confirm whether this metric's meaning does not include cases where super options are set to "ro".

The PR that caused this question: b9d0932

Host operating system: output of uname -a

Linux host 4.19.90-2307.3.0.el7.v60.x86_64 #1 SMP Mon Aug 26 14:27:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

node_exporter version: output of node_exporter --version

node_exporter, version 1.6.1 (branch: HEAD, revision: 4a1b776)
build user: root@586879db11e5
build date: 20230717-12:10:52
go version: go1.20.6
platform: linux/amd64
tags: netgo osusergo static_build

node_exporter command line flags

node_exporter log output

Are you running node_exporter in Docker?

no

What did you do that produced an error?

Make the root partition read-only

What did you expect to see?

The node_filesystem_readonly{mountpoint="/"} is set to 1 when the root partition is read-only.

What did you see instead?

The node_filesystem_readonly{mountpoint="/"} is set to 0 when the root partition is read-only.

@dswarbrick
Copy link
Contributor

dswarbrick commented Oct 18, 2024

In filesystem_linux.go, you can see that it parses the mount options from the sixth field group, i.e. rw,relatime in your case. It ignores the super-options completely.

Excerpt from mount(2) manpage:

       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 for the node_filesystem_readonly metric to have any real meaning, it would need to take both the per-mount options and per-superblock options into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants