prometheus / procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Apache License 2.0
769 stars 319 forks source link

Implement mdraid sysfs parsing #509

Closed dswarbrick closed 1 year ago

dswarbrick commented 1 year ago

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 https://github.com/prometheus/node_exporter/issues/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., https://github.com/prometheus/node_exporter/issues/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:

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

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

SuperQ commented 1 year ago

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

dswarbrick commented 1 year ago

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.