Statistiques
| Révision :

root / bin / get-disk-info @ 38

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

1
#!/bin/bash
2
SMARTTOOL="/usr/sbin/smartctl"
3

    
4

    
5

    
6
function usage {
7
  echo "Syntax :"
8
  echo "$0 -d device_name"
9
}
10

    
11
function nointeractive {
12

    
13
FIRST_TEST=$($SMARTTOOL $DEVBYID)
14
if [ $? -eq 0 ]
15
then
16
   while read line
17
   do
18
    if [[ "$line" =~ ":" ]]
19
    then
20
       echo $line
21
    fi 
22

    
23
   done <<< "$($SMARTTOOL -i -H $DEVBYID)"
24
   DEVBYIDNOPART=$(echo $DEVBYID |sed -e "s/\/dev\/disk\/by-vdev\///g" |sed -e "s/-part1$//g")
25
  # echo "DEVBYIDNOPART= $DEVBYIDNOPART"
26
   if [[ "$DEVBYIDNOPART" == "" ]] || [[ "$DEVBYIDNOPART-part1" == "$DEVBYID" ]]
27
   then
28
        DEVBYIDNOPART=$(echo $DEVBYID |sed -e "s/\/dev\/disk\/by-id\///g" |sed -e "s/-part1$//g")
29
        echo "DEVBYIDNOPART= $DEVBYIDNOPART"
30
   fi
31
   echo "nameinzpool:$DEVBYIDNOPART"
32
   errorread=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
33
   echo "errorread:$errorread"
34
   errorwrite=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
35
   echo "errorwrite:$errorwrite"
36
   errorchecksum=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
37
   echo "errorchecksum:$errorchecksum"
38
   exit 0
39
fi
40

    
41
if [[ -e /sbin/multipath ]] || [[ -e /usr/sbin/multipath ]] || [[ -e /usr/local/sbin/multipath ]]
42
then
43

    
44
    resultMulti=$(multipath -v 2 -l $DEVBYID |sed -e 's/(/disk_id=/g' |sed -e 's/)//g'|cut -d " " -f2 |grep disk_id|cut -d '=' -f2)
45
    if [ "$resultMulti" != ""  ]
46
    then
47
        while read liner
48
        do
49
          if [[ "$liner" =~ ":" ]]
50
          then
51
              echo $liner
52
          fi 
53
        done<<< "$($SMARTTOOL -i -H /dev/disk/by-id/scsi-$resultMulti)"
54
        DEVBYIDNOPART=$(echo $DEVBYID|cut -d "/" -f4)
55
        echo "nameinzpool:$DEVBYIDNOPART"
56
        errorread=$(/sbin/zpool status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
57
        echo "errorread:$errorread"
58
        errorwrite=$(/sbin/zpool status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
59
        echo "errorwrite:$errorwrite"
60
        errorchecksum=$(/sbin/zpool status |grep "$DEVBYIDNOPART "|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
61
        echo "errorchecksum:$errorchecksum"
62
        exit 0
63
    fi
64
fi
65

    
66
echo "no informations disk"
67
}
68

    
69
while getopts "d:h" OPTION
70
do
71
     case $OPTION in
72
         h)
73
             usage
74
             exit 1
75
             ;;
76
         d)
77
            DEVBYID=$OPTARG
78
            ;;
79
         *)
80
           usage
81
           exit 1
82
           ;;
83
     esac
84
done
85
if [[ -z $DEVBYID ]] 
86
then
87
     usage
88
     exit 1
89
fi
90

    
91
nointeractive
92