prometheus / procfs

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

Support parse raid type for mdstat #505

Open ImSingee opened 1 year ago

ImSingee commented 1 year ago

For something like

md6 : active raid1 sdb2[2](F) sdc[1](S) sda2[0]
md11 : active (auto-read-only) raid1 sdb2[0] sdc2[1] sdc3[2](F) hda[4](S) ssdc2[3](S)

We can also get the raid type from /proc/mdstat

SuperQ commented 1 year ago

This needs a DCO sign-off. You can use git commit -s --amend to add it.

ImSingee commented 1 year ago

@SuperQ Sorry that I forgot the sign-off in later commits😂. And now it's added.

ImSingee commented 1 year ago

@SuperQ There's a case that I cannot check (...) only

md219 : inactive sdb[2](S) sdc[1](S) sda[0](S)

If we only check parentheses, the type will be sdb[2](S)

But maybe we can assume the type does not contain any special characters?

ImSingee commented 1 year ago

@SuperQ I changed the code for type checking. It passes all current tests, and I hope it can work forever.

ImSingee commented 1 year ago

@SuperQ I considered this before. But there is another case...

md4 : inactive raid1 sda3[0](F) sdb3[1](S)
      4883648 blocks [2/2] [UU]

We can ignore the type for this, but it's here anyway and it may be useful in some case.

SuperQ commented 1 year ago

Ahh, crap, yea, that's a problem.

ImSingee commented 1 year ago

@SuperQ @discordianfish Because of the lack of some knowledge, let's keep this open and see if anyone can help.