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

Implement mdraid sysfs parsing #509

Merged
merged 1 commit into from
May 5, 2023
Merged

Conversation

dswarbrick
Copy link
Contributor

@dswarbrick dswarbrick commented Apr 24, 2023

Modernised method of fetching mdraid statistics via machine-readable sysfs entries, instead of parsing human-readable /proc/mdstat.

This would go a long way towards addressing prometheus/node_exporter#1085, as well as superseding / obsoleting various other pending PRs (#329) that attempt to squeeze a bit more info out of /proc/mdstat and issues, e.g., prometheus/node_exporter#1874

The mdraid sysfs entries contain significantly more detailed information that what is presented in the simplified and human-readable /proc/mdstat.

I'd like to get a few more eyeballs on this code, and have it alongside the existing /proc/mdstat parser initially, with a view to perhaps making the MDStat function a wrapper around the new sysfs parser eventually (or refactor node_exporter to use the new function directly). Existing MDStat members ActivityState, DisksDown, DisksFailed, DisksSpare, DisksTotal, DisksActive can be derived / counted / calculated from information exposed by the new Mdraid struct.

Some of the MDStat struct information is not exposed directly by /sys/block/md*/md, however it is obtainable via other means. For example:

  • BlocksTotal - this is technically redundant, since it is just the md block device size in KiB. This should be implemented generically for all block device types, i.e., by exposing /sys/block/*/size (measured in 512-byte sectors - yes, even on 4K sector drives).
  • BlocksSynced - sysfs will only expose this whilst an array is resyncing / recovering (or checking). Otherwise, it is to be assumed that all blocks are in sync.

Other MDStat struct members which are not currently used by node_exporter:

  • BlocksSyncedPct - superseded by SyncCompleted, which is a fraction (0-1) representing the completion status of current sync operation.
  • BlocksSyncedSpeed - no equivalent in sysfs, however this could be calculated in promql with the rate() function.
  • BlocksSyncedFinishTime - no equivalent in sysfs, however this could be calculated in promql by dividing the remaining blocks to sync by the sync speed.

@SuperQ I would greatly appreciate your review / input on this.

Modernised method of fetching mdraid statistics via machine-readable
sysfs entries, instead of parsing human-readable /proc/mdstat.

Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>
@SuperQ
Copy link
Member

SuperQ commented Apr 24, 2023

Nice, do we know how far back this kernel support goes?

@dswarbrick
Copy link
Contributor Author

dswarbrick commented Apr 24, 2023

Nice, do we know how far back this kernel support goes?

The mdraid sysfs stuff is pretty mature - it should go back as far as 2.6.x (yeah, for all those Synology NAS users...)

2.6.12 looks to contain the earliest documentation of mdraid sysfs interface: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/md.txt?h=v2.6.12, ca. April 2005.

Copy link
Member

@discordianfish discordianfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGMT. We can still support parsing both in the node-exporter.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

@SuperQ SuperQ merged commit 663692c into prometheus:master May 5, 2023
8 checks passed
@dswarbrick dswarbrick deleted the mdraid-sysfs branch May 19, 2023 14:21
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

Successfully merging this pull request may close these issues.

None yet

3 participants