Statistiques
| Révision :

root / bin / get-disk-info @ 1

Historique | Voir | Annoter | Télécharger (2,38 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-id\///g" |sed -e "s/-part1$//g")
25
   echo "nameinzpool:$DEVBYIDNOPART"
26
   errorread=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f3)
27
   echo "errorread:$errorread"
28
   errorwrite=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f4)
29
   echo "errorwrite:$errorwrite"
30
   errorchecksum=$(/sbin/zpool status |grep "$DEVBYIDNOPART"|sed -e "s/\t//g" |sed -e "s/ \+/ /g" | sed -e "s/^ //g"|cut -d " " -f5)
31
   echo "errorchecksum:$errorchecksum"
32
   exit 0
33
fi
34

    
35
if [[ -e /sbin/multipath ]] || [[ -e /usr/sbin/multipath ]] || [[ -e /usr/local/sbin/multipath ]]
36
then
37

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

    
60
echo "no informations disk"
61
}
62

    
63
while getopts "d:h" OPTION
64
do
65
     case $OPTION in
66
         h)
67
             usage
68
             exit 1
69
             ;;
70
         d)
71
            DEVBYID=$OPTARG
72
            ;;
73
         *)
74
           usage
75
           exit 1
76
           ;;
77
     esac
78
done
79
if [[ -z $DEVBYID ]] 
80
then
81
     usage
82
     exit 1
83
fi
84

    
85
nointeractive
86