Skip to contentSkip to conversation

Programmatically check "global" RAID state?

DISCUSSION Ian Pilcher 2 participants 2 messages Jul 16, 2020 MD RAID

lore
Share & tools
lore
#0 lore raw

I want to write a quick script/program for my NAS that will initiate a check of one of my RAID devices every night. However, I want it to skip the check if either of the following is true:

* Another check/resync is in process on any RAID device, or

* Any of the RAID devices on the system are unhealthy (degraded or failed).

Is there any way to programmatically check the "global" status of the RAID subsystem like this, or am I stuck iterating through all of the devices (likely via sysfs) and checking them individually? (I'm pretty sure that I am "stuck" but wanted to check just in case.)

Thanks!

Signature · 3 lines
========================================================================
                 In Soviet Russia, Google searches you!
========================================================================
#1 lore raw

Am 16.07.20 um 15:38 schrieb Ian Pilcher:

Quoted 6 lines

I want to write a quick script/program for my NAS that will initiate a check of one of my RAID devices every night.  However, I want it to skip the check if either of the following is true:

* Another check/resync is in process on any RAID device, or

Quoted 7 lines

* Any of the RAID devices on the system are unhealthy (degraded or failed).

Is there any way to programmatically check the "global" status of the RAID subsystem like this, or am I stuck iterating through all of the devices (likely via sysfs) and checking them individually?  (I'm pretty sure that I am "stuck" but wanted to check just in case.)

cat /proc/mdstat | grep -P 'cond1|cond2|cond3' should do the trick, if the output is empty: go