From 3b016ae797842c21b959c5246198330609052a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 20 Feb 2020 11:18:18 +0100 Subject: [PATCH] Set clear status if SMART is not supported --- xymon/plugins/client/ext/smart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xymon/plugins/client/ext/smart b/xymon/plugins/client/ext/smart index 96cd313..9011f6a 100755 --- a/xymon/plugins/client/ext/smart +++ b/xymon/plugins/client/ext/smart @@ -3,7 +3,7 @@ # NOTE: Must be run as root, so you probably need to setup sudo for this. # Vars {{{ -debug="0" +debug="1" ## Colors {{{ c_redb='\033[1;31m' @@ -50,7 +50,6 @@ is_disk_support_smart() { } ## }}} - if test -f /tmp/dres; then rm -f /tmp/dres; fi if test -f /tmp/dscan; then rm -f /tmp/dscan; fi @@ -64,9 +63,18 @@ while IFS= read -r LINE; do is_disk_support_smart "${DISK}" "${TYPE}" - ## Get SMART Health Status and return code - DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}") - DCODE=$? + ## If SMART is supported on the disk + if [ -z "${smart_support_msg}" ]; then + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : SMART seems fully supported, proceed normally." + ### Get SMART Health Status and return code + DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}") + DCODE=$? + else + [ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : SMART is not fully supported, get ." + DRES=$(printf '%s' "${smart_support_msg}") + DCODE="2" + fi + DSTBY=$(( DCODE & 2 )) DFAIL=$(( DCODE & 8 )) DWARN=$(( DCODE & 32 ))