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