From 393f9996d299359101889722ac1bbce86dc31c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 19 Feb 2020 11:18:25 +0100 Subject: [PATCH] Get disk list from smartctl scan --- xymon/plugins/client/ext/smart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xymon/plugins/client/ext/smart b/xymon/plugins/client/ext/smart index 88c5f7c..ffaec6e 100755 --- a/xymon/plugins/client/ext/smart +++ b/xymon/plugins/client/ext/smart @@ -2,18 +2,18 @@ # NOTE: Must be run as root, so you probably need to setup sudo for this. -# Thanks to xymon.com − https://www.xymon.com/xymon-cgi/viewconf.sh?smart - if test -f /tmp/dres; then rm -f /tmp/dres; fi +smartctl --scan > /tmp/dscan # MODIFY below to match your setup - the "scsi-SATA" is pretty generic, but you # can add more disks if you like. E.g. I have a USB disk permanently plugged in. -ls /dev/disk/by-id/scsi-SATA_* /dev/disk/by-id/usb-WD* | grep -v -- -part | sort | -while read DISK +while read LINE do - DRES=`/usr/sbin/smartctl -H -n standby $DISK` + DISK=$(echo "${LINE}" | cut -d" " -f1) + TYPE=$(echo "${LINE}" | cut -d" " -f3) + DRES=`/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}"` DCODE=$? DSTBY=$(( $DCODE & 2 )) DFAIL=$(( $DCODE & 8 )) @@ -32,15 +32,15 @@ do COLOR="3&green" fi - echo "${COLOR} $DISK" + echo "${COLOR} $DISK ${TYPE}" - echo "${COLOR} $DISK" | cut -c2- >>/tmp/dres + echo "${COLOR} $DISK ${TYPE}" | cut -c2- >>/tmp/dres echo "" >>/tmp/dres echo "$DRES" | egrep -v "^smartctl|^Copyright|^$|^===" >>/tmp/dres echo "------------------------------------------------------------" >>/tmp/dres echo "" >>/tmp/dres echo "" >>/tmp/dres -done >/tmp/dcheck +done < /tmp/dscan >/tmp/dcheck COLOR=`cat /tmp/dcheck | awk '{print $1}' | sort | uniq | head -1 | cut -c3-` @@ -53,7 +53,7 @@ $XYMON $XYMSRV "status ${MACHINE}.smart ${COLOR} SMART health check `cat /tmp/dres` " -rm -f /tmp/dres /tmp/dcheck +rm -f /tmp/dres /tmp/dcheck /tmp/dscan exit 0