From beee18371c9bce1943d3ab3f4adc90ba5effa421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 20 Feb 2020 18:43:23 +0100 Subject: [PATCH] Display additionnal device info in detail --- xymon/plugins/client/ext/smart | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/xymon/plugins/client/ext/smart b/xymon/plugins/client/ext/smart index 4dc6094..79f95f6 100755 --- a/xymon/plugins/client/ext/smart +++ b/xymon/plugins/client/ext/smart @@ -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