Skip to content

Commit 6b7d19c

Browse files
authored
Modified formatting
Changed formatting to accommodate lengthier command timeout values and enhanced the drive identifier to include vendor, model, family, etc.
1 parent 3350851 commit 6b7d19c

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

smart_report.sh

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ if [ $SATA_count -gt 0 ]; then
8888
(
8989
echo "########## SMART status report summary for all SATA drives on server ${freenashost} ##########"
9090
echo ""
91-
echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"
92-
echo "|Device|Serial |Temp|Power|Start|Spin |ReAlloc|Current|Offline |Seek |Total |High |Command|Last|"
93-
echo "| |Number | |On |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks |Fly |Timeout|Test|"
94-
echo "| | | |Hours|Count|Count| |Sectors|Sectors | | |Writes|Count |Age |"
95-
echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"
91+
echo "+------+------------------------+----+------+-----+-----+-------+-------+--------+------+----------+------+-----------+----+"
92+
echo "|Device|Serial |Temp| Power|Start|Spin |ReAlloc|Current|Offline |Seek |Total |High | Command|Last|"
93+
echo "| |Number | | On |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks |Fly | Timeout|Test|"
94+
echo "| | | | Hours|Count|Count| |Sectors|Sectors | | |Writes| Count |Age |"
95+
echo "+------+------------------------+----+------+-----+-----+-------+-------+--------+------+----------+------+-----------+----+"
9696
) >> "$logfile"
9797

9898
###### Detail information for each SATA drive ######
@@ -128,29 +128,21 @@ if [ $SATA_count -gt 0 ]; then
128128
seekErrors="N/A";
129129
totalSeeks="N/A";
130130
}
131-
132131
if (temp > tempWarn || temp > tempCrit) temp=temp"*"
133-
134132
if (reAlloc > 0 || reAlloc > sectorsCrit) reAlloc=reAlloc"*"
135-
136133
if (pending > 0 || pending > sectorsCrit) pending=pending"*"
137-
138134
if (offlineUnc > 0 || offlineUnc > sectorsCrit) offlineUnc=offlineUnc"*"
139-
140135
if (testAge > testAgeWarn) testAge=testAge"*"
141-
142136
if (hiFlyWr == "") hiFlyWr="N/A";
143-
144137
if (cmdTimeout == "") cmdTimeout="N/A";
145-
146-
printf "|%-6s|%-24s|%-4s|%5s|%5s|%5s|%7s|%7s|%8s|%6s|%10s|%6s|%7s|%4s|\n",
138+
printf "|%-6s|%-24s|%-4s|%6s|%5s|%5s|%7s|%7s|%8s|%6s|%10s|%6s|%11s|%4s|\n",
147139
device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc,
148140
seekErrors, totalSeeks, hiFlyWr, cmdTimeout, testAge;
149141
}'
150142
) >> "$logfile"
151143
done
152144
(
153-
echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"
145+
echo "+------+------------------------+----+------+-----+-----+-------+-------+--------+------+----------+------+-----------+----+"
154146
) >> "$logfile"
155147
fi
156148

@@ -206,14 +198,25 @@ if [ $SATA_count -gt 0 ] || [ $SAS_count -gt 0 ]; then
206198

207199
###### Emit SATA drive information ######
208200
for drive in $SATA_list; do
209-
brand=$("$smartctl" -i "$drive" | grep "Model Family" | awk '{print $3, $4, $5, $6, $7}')
210-
if [ -z "$brand" ]; then
211-
brand=$("$smartctl" -i "$drive" | grep "Device Model" | awk '{print $3, $4, $5, $6, $7}')
201+
vendor=$("$smartctl" -i "$drive" | grep "Vendor:" | awk '{print $NF}')
202+
if [ -z "$vendor" ]; then
203+
dfamily=$("$smartctl" -i "$drive" | grep "Model Family" | awk '{print $3, $4, $5, $6, $7}' | sed -e 's/[[:space:]]*$//')
204+
dmodel=$("$smartctl" -i "$drive" | grep "Device Model" | awk '{print $3, $4, $5, $6, $7}' | sed -e 's/[[:space:]]*$//')
205+
if [ -z "$dfamily" ]; then
206+
dinfo=$dmodel
207+
else
208+
dinfo="$dfamily ($dmodel)"
209+
fi
210+
else
211+
product=$("$smartctl" -i "$drive" | grep "Product:" | awk '{print $NF}')
212+
revision=$("$smartctl" -i "$drive" | grep "Revision:" | awk '{print $NF}')
213+
dinfo="$vendor $product $revision"
212214
fi
213215
serial=$("$smartctl" -i "$drive" | grep "Serial Number" | awk '{print $3}')
214216
(
215217
echo ""
216-
echo "########## SMART status for SATA drive $drive $serial (${brand}) ##########"
218+
echo "########## SATA drive $drive Serial: $serial"
219+
echo "########## ${dinfo}"
217220
"$smartctl" -n never -H -A -l error "$drive"
218221
"$smartctl" -n never -l selftest "$drive" | grep "# 1 \\|Num" | cut -c6-
219222
) >> "$logfile"

0 commit comments

Comments
 (0)