Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
craig
GitHub Repository: craig/ge.mine.nu
Path: blob/master/website/code/seagate-207931-3.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
checkmodel()
38
{
39
for ((k=0; k<${#MODEL[@]}; k++))
40
do
41
if [ -n "$(echo $@ | grep ${MODEL[${k}]})" ]
42
then
43
return 1
44
fi
45
done
46
return 0
47
}
48
49
checkperms()
50
{
51
if [ -r "${@}" ]
52
then
53
return 1
54
else
55
return 0
56
fi
57
}
58
59
# as you get this for free, I'll add a banner at least ;)
60
echo
61
echo "seagate-207931.sh v2 by Stefan Behte (http://ge.mine.nu)"
62
echo
63
64
# hdparm
65
if [ -e "${HDPARM}" ]
66
then
67
DEVICE=($(sed -e 's/[0-9]//g' /proc/partitions | grep -v -e ^major -e dm- -e ^$ | awk '{print $1}' | uniq))
68
for ((i=0; i<${#DEVICE[@]}; i++))
69
do
70
checkperms /dev/${DEVICE[${i}]}
71
if [ $? -eq 0 ]
72
then
73
echo "Error reading /dev/${DEVICE[${i}]}"
74
break
75
fi
76
77
DUMP=$($HDPARM -I /dev/${DEVICE[${i}]} 2>/dev/null | grep -e "Model Number" -e "Serial Number" -e "Firmware Revision")
78
checkmodel ${DUMP}
79
if [ $? -eq 1 ]
80
then
81
echo "Model might be affected."
82
echo ${DUMP}
83
echo "Go to https://apps1.seagate.com/rms_af_srl_chk/ and paste the serial there."
84
else
85
echo "hdparm /dev/${DEVICE[${i}]} ok"
86
fi
87
done
88
else
89
echo "hdparm not found"
90
fi
91
92
echo
93
94
# 3ware RAID, check every port on every controller
95
if [ -e "${TW_CLI}" ]
96
then
97
CONTROLLER=$(${TW_CLI} show | awk '/^c/ {print $1}')
98
99
if [ ! -x "${TW_CLI}" ]
100
then
101
echo "Error: cannot execute ${TW_CLI}. Results will be wrong!"
102
fi
103
104
for ((i=0; i<${#CONTROLLER[@]}; i++))
105
do
106
PORT=($(${TW_CLI} /${CONTROLLER[${i}]} show | awk '/^p/ {print $1}'))
107
108
for ((j=0; j<${#PORT[@]}; j++))
109
do
110
DUMP=$(${TW_CLI} /${CONTROLLER[${i}]}/${PORT[${j}]} show model serial firmware)
111
checkmodel ${DUMP}
112
if [ $? -eq 1 ]
113
then
114
FOUND=1
115
116
echo "Your model might be affected."
117
echo ${DUMP}
118
echo "Go to https://apps1.seagate.com/rms_af_srl_chk/ and paste the serial there."
119
else
120
echo "3ware (tw_cli) /${CONTROLLER[${i}]}/${PORT[${j}]}: ok"
121
fi
122
done
123
done
124
else
125
echo "tw_cli not found"
126
fi
127
128
# Adaptec, only tested with Version 6.0 (B17914), query physical drives on all controllers
129
if [ -e "${ARCCONF}" ]
130
then
131
NR=$(${ARCCONF} GETSTATUS 23 | awk -F: '/Controllers found/ {print $2}')
132
for ((i=0;i<$NR;i++))
133
do
134
DUMP=$(${ARCCONF} GETCONFIG $[${i} + 1] PD | grep -e Model -e Firmware -e Serial)
135
checkmodel ${DUMP}
136
if [ $? -eq 1 ]
137
then
138
FOUND=1
139
140
echo "Your model might be affected."
141
echo ${DUMP}
142
echo "Go to https://apps1.seagate.com/rms_af_srl_chk/ and paste the serial there."
143
else
144
echo "Adaptec (arcconf) $[${i} + 1]: ok"
145
fi
146
done
147
else
148
echo "arcconf not found"
149
fi
150
151
if [ "${FOUND}" = "0" ]
152
then
153
echo
154
echo "Good luck, no Seagate drives for KB 207931 found."
155
echo "If this machine has a RAID-Controller other than 3ware or adaptec (used with arcconf), this tool probably has failed."
156
echo "Please review the code and send your changes. ;)"
157
echo
158
exit 0
159
else
160
echo
161
exit 1
162
fi
163
164
165