Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
craig
GitHub Repository: craig/ge.mine.nu
Path: blob/master/website/code/seagate-207931-2.sh
100 views
1
#!/bin/bash
2
# Seagate drives (Barracuda 7200.11, DiamondMax 22, Barracuda ES.2 SATA, SV35) fail after powering on, KB 207931:
3
# http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?Tab=search&Module=selfservice&TargetLanguage=selfservice&DocId=207931&NewLang=en
4
#
5
# There is no Linux tool (yet) to help the overworked linux admin,
6
# so I wrote this - have fun mass-checking your servers.
7
#
8
# Currently supports hdparm, tw_cli (3ware), arcconf (adaptec)
9
# You have to use the corresponding RAID-Tool in order to get the model, serial and firmware version.
10
#
11
# Hint:
12
# do something like this:
13
# ssh host "curl -s https://deploysrv/seagate-207931.sh | sh"
14
#
15
# The script has return codes:
16
# 0: everything ok
17
# 1: one of the models was found (you still need to check the firmware version)
18
#
19
# If you have code additions, mail me, I'd like to add support for more cli raid-tools.
20
# Please supply me with complete output - or just buy me an areca, lsi and I'll add support for those, too ;)
21
#
22
# Written by Stefan Behte (http://ge.mine.nu)
23
# Stefan dot Behte at gmx dot net
24
25
# from KB 207931
26
MODEL=(ST31000340AS ST31000640AS ST3750330AS ST3750630AS ST3640330AS ST3640630AS ST3500320AS ST3500620AS ST3500820AS ST31500341AS ST31000333AS ST3640323AS ST3640623AS ST3320613AS ST3320813AS ST3160813AS ST31000340NS ST3750330NS ST3500320NS ST3250310NS STM31000340AS STM31000640AS STM3750330AS STM3750630AS STM3500320AS STM3500620AS STM3500820AS STM31000334AS STM3320614AS STM3160813AS)
27
28
HDPARM=$(which hdparm 2>/dev/null)
29
TW_CLI=$(which tw_cli 2>/dev/null)
30
31
# not in PATH, rpm installed it there
32
ARCCONF="/usr/StorMan/arcconf"
33
CURL=$(which curl 2>/dev/null)
34
35
FOUND=0
36
37
checkserial()
38
{
39
if [ ! -x $CURL ]
40
then
41
echo "cannot execute curl."
42
fi
43
44
RESULT=$($CURL -s https://apps1.seagate.com/rms_af_srl_chk/checkSerialServlet --data "serialno=${@}&serialnumber=${@}" -A http://ge.mine.nu/seagate-207931.html)
45
46
if [ ! -n "$(echo "${RESULT}" | grep -q "is NOT affected")" ]
47
then
48
echo "Serial not found, good luck."
49
echo
50
FOUND=0
51
else
52
echo "Serial found, bad luck."
53
echo
54
FOUND=1
55
fi
56
}
57
58
checkmodel()
59
{
60
for ((k=0; k<${#MODEL[@]}; k++))
61
do
62
if [ -n "$(echo $@ | grep ${MODEL[${k}]})" ]
63
then
64
return 1
65
fi
66
done
67
return 0
68
}
69
70
checkperms()
71
{
72
if [ -r "${@}" ]
73
then
74
return 1
75
else
76
return 0
77
fi
78
}
79
80
# as you get this for free, I'll add a banner at least ;)
81
echo
82
echo "seagate-207931.sh v2 by Stefan Behte (http://ge.mine.nu)"
83
echo
84
85
# hdparm
86
if [ -e "${HDPARM}" ]
87
then
88
DEVICE=($(sed -e 's/[0-9]//g' /proc/partitions | grep -v -e ^major -e dm- -e ^$ | awk '{print $1}' | uniq))
89
for ((i=0; i<${#DEVICE[@]}; i++))
90
do
91
checkperms /dev/${DEVICE[${i}]}
92
if [ $? -eq 0 ]
93
then
94
echo "Error reading /dev/${DEVICE[${i}]}"
95
break
96
fi
97
98
DUMP=$($HDPARM -I /dev/${DEVICE[${i}]} 2>/dev/null | grep -e "Model Number" -e "Serial Number" -e "Firmware Revision")
99
checkmodel ${DUMP}
100
if [ $? -eq 1 ]
101
then
102
echo "Model might be affected."
103
echo ${DUMP}
104
echo -n "Querying seagate server..."
105
checkserial $($HDPARM -I /dev/${DEVICE[${i}]} 2>/dev/null | awk '/Serial Number/ {print $3}')
106
else
107
echo "hdparm /dev/${DEVICE[${i}]} ok"
108
fi
109
done
110
else
111
echo "hdparm not found"
112
fi
113
114
echo
115
116
# 3ware RAID, check every port on every controller
117
if [ -e "${TW_CLI}" ]
118
then
119
CONTROLLER=$(${TW_CLI} show | awk '/^c/ {print $1}')
120
121
if [ ! -x "${TW_CLI}" ]
122
then
123
echo "Error: cannot execute ${TW_CLI}. Results will be wrong!"
124
fi
125
126
for ((i=0; i<${#CONTROLLER[@]}; i++))
127
do
128
PORT=($(${TW_CLI} /${CONTROLLER[${i}]} show | awk '/^p/ {print $1}'))
129
130
for ((j=0; j<${#PORT[@]}; j++))
131
do
132
DUMP=$(${TW_CLI} /${CONTROLLER[${i}]}/${PORT[${j}]} show model serial firmware)
133
checkmodel ${DUMP}
134
if [ $? -eq 1 ]
135
then
136
FOUND=1
137
138
echo "Your model might be affected."
139
echo ${DUMP}
140
echo -n "Querying seagate server: "
141
checkserial $(${TW_CLI} /${CONTROLLER[${i}]}/${PORT[${j}]} show serial | awk '{print $4}')
142
else
143
echo "3ware (tw_cli) /${CONTROLLER[${i}]}/${PORT[${j}]}: ok"
144
fi
145
done
146
done
147
else
148
echo "tw_cli not found"
149
fi
150
151
# Adaptec, only tested with Version 6.0 (B17914), query physical drives on all controllers
152
if [ -e "${ARCCONF}" ]
153
then
154
NR=$(${ARCCONF} GETSTATUS 23 | awk -F: '/Controllers found/ {print $2}')
155
for ((i=0;i<$NR;i++))
156
do
157
DUMP=$(${ARCCONF} GETCONFIG $[${i} + 1] PD | grep -e Model -e Firmware -e Serial)
158
checkmodel ${DUMP}
159
if [ $? -eq 1 ]
160
then
161
FOUND=1
162
163
echo "Your model might be affected."
164
echo ${DUMP}
165
echo -n "Querying seagate server: "
166
167
SERIAL=($(${ARCCONF} GETCONFIG $[${i} + 1] PD | awk '/Serial number/ {printf $4 " "}'))
168
for ((l=0; l<${#SERIAL[@]}; l++))
169
do
170
checkserial ${SERIAL[${l}]}
171
done
172
else
173
echo "Adaptec (arcconf) $[${i} + 1]: ok"
174
fi
175
done
176
else
177
echo "arcconf not found"
178
fi
179
180
if [ "${FOUND}" = "0" ]
181
then
182
echo
183
echo "Good luck, no Seagate drives for KB 207931 found."
184
echo "If this machine has a RAID-Controller other than 3ware or adaptec (used with arcconf), this tool probably has failed."
185
echo "Please review the code and send your changes. ;)"
186
echo
187
exit 0
188
else
189
echo
190
exit 1
191
fi
192
193
194