Statistiques
| Révision :

root / bin / get-disk-zpool @ 26

Historique | Voir | Annoter | Télécharger (2,1 ko)

1
#!/bin/bash
2

    
3
function usage {
4

    
5
echo "Syntax $0"
6
echo "Description : Get and write in a file all disk (type raidz and mirror) of a ZFS"
7

    
8
}
9

    
10
function nointeractive {
11
zdb >/tmp/.buffer_zdb
12
GETDISKINFO="/sbin/get-disk-info"
13

    
14
dataType=""
15
raidType=""
16
raidID=""
17
nparity=""
18
poolname=""
19

    
20
while read line
21
do
22
   strLine=$(echo $line |sed -e 's/ \+//g'|sed -e "s/'//g")
23
   property=$(echo $strLine |cut -d ':' -f1)
24
   valueProperty=$(echo $strLine |cut -d ':' -f2)
25
   if [ "$property" == "name" ]
26
   then
27
      echo "$property:$valueProperty"
28
      echo "$(zpool status $valueProperty|grep -i "state:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")"
29
      echo "$(zpool status $valueProperty|grep -i "scan:"|sed -e "s/^ \+//g"|sed -e "s/: /:/")"
30
      poolname="$valueProperty"
31
   fi
32
   if [[ "$property" =~ "children[" ]]
33
   then
34
       continue;      
35
   fi
36
   if [[ "$property" == "type" ]] && [[ "$valueProperty" == "raidz" ]]
37
   then
38
      dataType="raidz"
39
      raidType="raidz"
40
   fi
41
   
42
   if [[ "$property" == "type" ]] && [[ "$valueProperty" == "mirror" ]]
43
   then
44
      dataType="mirror"
45
      raidType="mirror"
46
   fi
47
  
48
   if [[ "$dataType" == "raidz" ]] || [[ "$dataType" == "mirror" ]]
49
   then
50
      if [ "$property" == "id" ]
51
      then
52
         raidID=$valueProperty
53
         
54
      fi
55
   fi
56
   if [[ "$dataType" == "raidz"  ]] && [[ "$property" == "nparity" ]]
57
   then
58
        nparity="$valueProperty"
59
   fi
60
    
61
   if [[ "$property" == "type" ]] && [[ "$valueProperty" == "disk" ]]
62
   then
63
      dataType="disk"
64
   fi
65
   
66
   if [ "$dataType" == "disk" ]
67
   then
68
      if [[ "$property" == "path" ]] && [[ "$valueProperty" != "" ]]
69
      then
70
        echo "#infoDisk#"
71
        echo "poolname:$poolname"
72
        echo "raidType:$raidType"
73
        echo "nparity:$nparity" 
74
        echo "raidID:$raidID"
75
        echo "$property:$valueProperty"
76
        $GETDISKINFO -d $valueProperty
77
      fi
78
   fi
79
   
80

    
81
done < "/tmp/.buffer_zdb"
82
echo "#infoDisk#"
83
}
84

    
85
while getopts "h" OPTION
86
do
87
     case $OPTION in
88
         h)
89
             usage
90
             exit 1
91
             ;;
92
         *)
93
           usage
94
           exit 1
95
           ;;
96
     esac
97
done
98

    
99
nointeractive