OpManager Raid Monitroing script

kdean

New Member
Joined
Jan 17, 2020
Messages
5
Reaction score
0
Credits
0
I am trying to make the following script echo 0 for all raid drives that come back with a 'U' and a 1 when it returns a '_' for raid drive down. However it still print [UU] or [__]

Bash:
#!/bin/bash

mdstat=$(cat /proc/mdstat | awk '{print $6}' | grep -A1 'sd' | grep U)

0='U'
1='_'

if [$mdstat = 1]
then
        echo '0'
else
        echo '1'
fi

#The code below basically tells our monitoring system the output of the script. 
#This is the only way we can get it to alert for raid.
#We use OpManager for Network and Server monitoring. 
echo "Data:"
echo "mdstat\t$mdstat"

What am i conceptually doing wrong here?
 
Last edited:


Actually ended up using mdadm tool to accomplish it. Works like a charm. This will work with OpManager. Just set the Critical threshold to 1 and the rearm to 0, no need to set attention or trouble threshold. I hope this helps someone one day. You can edit line 3 to include as many arrays as you want for example,
mdadm --detail --test /dev/md1 /dev/md3 /dev/md4 /dev/md5 /dev/md6 /dev/md7 ... /dev/md129 2>&1 > /dev/null, etc etc etc

Code:
#!/bin/bash

mdadm --detail --test /dev/md1 /dev/md3 /dev/md4 2>&1 > /dev/null

mdstatus=$?

if [[ $mdstatus -eq 0 ]]; then
        echo 0
else
        echo 1
fi

echo "Data:"
echo -e "RAID\t$mdstatus"
 

Members online


Latest posts

Top