comya avatar

shell腳步監控SoftRaid的N種寫法分享

🕚 by comya

shell腳步監控SoftRaid的N種寫法分享

Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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

echo "Data:"
echo "mdstat\t$mdstat"
Bash:
1
2
3
4
5
6
7
#!/bin/bash
                                                                                                                                                             mdadm --detail --test /dev/md127 2>&1 > /dev/null                                                                                                            mdstatus=$?                                                                                                                                                  
if [[ $mdstatus -eq 0 ]]; then
        echo 0
else
        echo 1
fi                                                                                                                                                                                

Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

mdstat=$(cat /proc/mdstat | grep "U" | awk '{print $NF}')

2='U'
3='_'

if [$mdstat = 2]
then
        echo '2'
else
        echo '3' 
fi

echo "Data:"
echo "mdstat\t$mdstat"

Bash:
1
2
3
4
5
6
7
#!/bin/bash
                                                                                                                                                             mdadm --detail --test /dev/md127 2>&1 > /dev/null                                                                                                            mdstatus=$?                                                                                                                                                  
if [[ $mdstatus -eq 0 ]]; then
        echo 0
else
        echo 1
fi                 

Bash:
1
2
3
4
5
6
7
8
9
10
11
#!/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

Bash:
1
2
3
4
5
6
7
#!/bin/bash
                                                                                                                                                             mdadm --detail --test /dev/md127 2>&1 > /dev/null                                                                                                            mdstatus=$?                                                                                                                                                  
if [[ $mdstatus -eq 0 ]]; then
        echo 0
else
        echo 1
fi            

💘 相关文章

写一条评论