Statistiques
| Révision :

root / bin / get-disk-zpool @ 39

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

1
#!/bin/bash
2
# $Id: get-disk-zpool 39 2013-10-08 12:46:21Z ltaulell $
3

    
4
function usage {
5

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

    
9
}
10

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

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

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

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

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

    
100
nointeractive