mirror of
https://github.com/Spearfoot/FreeNAS-scripts
synced 2025-12-13 06:43:28 +00:00
Modified formatting
Changed formatting to accommodate lengthier command timeout values and enhanced the drive identifier to include vendor, model, family, etc.
This commit is contained in:
@@ -88,11 +88,11 @@ if [ $SATA_count -gt 0 ]; then
|
|||||||
(
|
(
|
||||||
echo "########## SMART status report summary for all SATA drives on server ${freenashost} ##########"
|
echo "########## SMART status report summary for all SATA drives on server ${freenashost} ##########"
|
||||||
echo ""
|
echo ""
|
||||||
echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"
|
echo "+------+------------------------+----+------+-----+-----+-------+-------+--------+------+----------+------+-----------+----+"
|
||||||
echo "|Device|Serial |Temp|Power|Start|Spin |ReAlloc|Current|Offline |Seek |Total |High |Command|Last|"
|
echo "|Device|Serial |Temp| Power|Start|Spin |ReAlloc|Current|Offline |Seek |Total |High | Command|Last|"
|
||||||
echo "| |Number | |On |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks |Fly |Timeout|Test|"
|
echo "| |Number | | On |Stop |Retry|Sectors|Pending|Uncorrec|Errors|Seeks |Fly | Timeout|Test|"
|
||||||
echo "| | | |Hours|Count|Count| |Sectors|Sectors | | |Writes|Count |Age |"
|
echo "| | | | Hours|Count|Count| |Sectors|Sectors | | |Writes| Count |Age |"
|
||||||
echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"
|
echo "+------+------------------------+----+------+-----+-----+-------+-------+--------+------+----------+------+-----------+----+"
|
||||||
) >> "$logfile"
|
) >> "$logfile"
|
||||||
|
|
||||||
###### Detail information for each SATA drive ######
|
###### Detail information for each SATA drive ######
|
||||||
@@ -128,29 +128,21 @@ if [ $SATA_count -gt 0 ]; then
|
|||||||
seekErrors="N/A";
|
seekErrors="N/A";
|
||||||
totalSeeks="N/A";
|
totalSeeks="N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (temp > tempWarn || temp > tempCrit) temp=temp"*"
|
if (temp > tempWarn || temp > tempCrit) temp=temp"*"
|
||||||
|
|
||||||
if (reAlloc > 0 || reAlloc > sectorsCrit) reAlloc=reAlloc"*"
|
if (reAlloc > 0 || reAlloc > sectorsCrit) reAlloc=reAlloc"*"
|
||||||
|
|
||||||
if (pending > 0 || pending > sectorsCrit) pending=pending"*"
|
if (pending > 0 || pending > sectorsCrit) pending=pending"*"
|
||||||
|
|
||||||
if (offlineUnc > 0 || offlineUnc > sectorsCrit) offlineUnc=offlineUnc"*"
|
if (offlineUnc > 0 || offlineUnc > sectorsCrit) offlineUnc=offlineUnc"*"
|
||||||
|
|
||||||
if (testAge > testAgeWarn) testAge=testAge"*"
|
if (testAge > testAgeWarn) testAge=testAge"*"
|
||||||
|
|
||||||
if (hiFlyWr == "") hiFlyWr="N/A";
|
if (hiFlyWr == "") hiFlyWr="N/A";
|
||||||
|
|
||||||
if (cmdTimeout == "") cmdTimeout="N/A";
|
if (cmdTimeout == "") cmdTimeout="N/A";
|
||||||
|
printf "|%-6s|%-24s|%-4s|%6s|%5s|%5s|%7s|%7s|%8s|%6s|%10s|%6s|%11s|%4s|\n",
|
||||||
printf "|%-6s|%-24s|%-4s|%5s|%5s|%5s|%7s|%7s|%8s|%6s|%10s|%6s|%7s|%4s|\n",
|
|
||||||
device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc,
|
device, serial, temp, onHours, startStop, spinRetry, reAlloc, pending, offlineUnc,
|
||||||
seekErrors, totalSeeks, hiFlyWr, cmdTimeout, testAge;
|
seekErrors, totalSeeks, hiFlyWr, cmdTimeout, testAge;
|
||||||
}'
|
}'
|
||||||
) >> "$logfile"
|
) >> "$logfile"
|
||||||
done
|
done
|
||||||
(
|
(
|
||||||
echo "+------+------------------------+----+-----+-----+-----+-------+-------+--------+------+----------+------+-------+----+"
|
echo "+------+------------------------+----+------+-----+-----+-------+-------+--------+------+----------+------+-----------+----+"
|
||||||
) >> "$logfile"
|
) >> "$logfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -206,14 +198,25 @@ if [ $SATA_count -gt 0 ] || [ $SAS_count -gt 0 ]; then
|
|||||||
|
|
||||||
###### Emit SATA drive information ######
|
###### Emit SATA drive information ######
|
||||||
for drive in $SATA_list; do
|
for drive in $SATA_list; do
|
||||||
brand=$("$smartctl" -i "$drive" | grep "Model Family" | awk '{print $3, $4, $5, $6, $7}')
|
vendor=$("$smartctl" -i "$drive" | grep "Vendor:" | awk '{print $NF}')
|
||||||
if [ -z "$brand" ]; then
|
if [ -z "$vendor" ]; then
|
||||||
brand=$("$smartctl" -i "$drive" | grep "Device Model" | awk '{print $3, $4, $5, $6, $7}')
|
dfamily=$("$smartctl" -i "$drive" | grep "Model Family" | awk '{print $3, $4, $5, $6, $7}' | sed -e 's/[[:space:]]*$//')
|
||||||
|
dmodel=$("$smartctl" -i "$drive" | grep "Device Model" | awk '{print $3, $4, $5, $6, $7}' | sed -e 's/[[:space:]]*$//')
|
||||||
|
if [ -z "$dfamily" ]; then
|
||||||
|
dinfo=$dmodel
|
||||||
|
else
|
||||||
|
dinfo="$dfamily ($dmodel)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
product=$("$smartctl" -i "$drive" | grep "Product:" | awk '{print $NF}')
|
||||||
|
revision=$("$smartctl" -i "$drive" | grep "Revision:" | awk '{print $NF}')
|
||||||
|
dinfo="$vendor $product $revision"
|
||||||
fi
|
fi
|
||||||
serial=$("$smartctl" -i "$drive" | grep "Serial Number" | awk '{print $3}')
|
serial=$("$smartctl" -i "$drive" | grep "Serial Number" | awk '{print $3}')
|
||||||
(
|
(
|
||||||
echo ""
|
echo ""
|
||||||
echo "########## SMART status for SATA drive $drive $serial (${brand}) ##########"
|
echo "########## SATA drive $drive Serial: $serial"
|
||||||
|
echo "########## ${dinfo}"
|
||||||
"$smartctl" -n never -H -A -l error "$drive"
|
"$smartctl" -n never -H -A -l error "$drive"
|
||||||
"$smartctl" -n never -l selftest "$drive" | grep "# 1 \\|Num" | cut -c6-
|
"$smartctl" -n never -l selftest "$drive" | grep "# 1 \\|Num" | cut -c6-
|
||||||
) >> "$logfile"
|
) >> "$logfile"
|
||||||
|
|||||||
Reference in New Issue
Block a user