Display additionnal device info in detail

This commit is contained in:
Jeremy Gardais 2020-02-20 18:43:23 +01:00
parent 8a3c0de8e4
commit beee18371c
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 18 additions and 12 deletions

View File

@ -102,7 +102,7 @@ if test -s /tmp/dscan; then
## If no correct type was found for this device
if [ -z "${TYPE}" ]; then
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG: SMART is not fully supported."
DRES=$(printf '%s' "${SMART_SUPPORT_MSG}")
DRES=$(printf '%s' "SMART Health Status can't be determine because of:\n${SMART_SUPPORT_MSG}")
DCODE="2"
TYPE="unsupported"
else
@ -110,6 +110,8 @@ if test -s /tmp/dscan; then
### Get SMART Health Status and return code
DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}")
DCODE=$?
DID=$(smartctl -i -d "${TYPE}" "${DISK}" | awk '/.erial .umber:/ { print $NF }')
DINFO=$(smartctl -i -d "${TYPE}" "${DISK}" | grep -v -E "^smartctl|^Copyright|^$")
fi
## Test health status
@ -131,18 +133,22 @@ if test -s /tmp/dscan; then
COLOR="3&green"
fi
## For summary
echo "${COLOR} $DISK ${TYPE}"
## Avoid duplicate device
if ! grep -q "${DID}" /tmp/dres; then
## For summary
echo "${COLOR} $DISK ${TYPE}"
## For detailed informations
{
echo "${COLOR} $DISK ${TYPE}" | cut -c2-
echo ""
echo "$DRES" | grep -v -E "^smartctl|^Copyright|^$|^==="
echo "------------------------------------------------------------"
echo ""
echo ""
} >> /tmp/dres
## For detailed informations
{
echo "${COLOR} $DISK ${TYPE}" | cut -c2-
echo ""
echo "$DRES" | grep -v -E "^smartctl|^Copyright|^$|^==="
echo "${DINFO}"
echo "------------------------------------------------------------"
echo ""
echo ""
} >> /tmp/dres
fi
done < /tmp/dscan >> /tmp/dcheck
# If the file is empty