summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/xymon-smart.sh
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/xymon/xymon-smart.sh')
-rwxr-xr-xabs/core/xymon/xymon-smart.sh23
1 files changed, 18 insertions, 5 deletions
diff --git a/abs/core/xymon/xymon-smart.sh b/abs/core/xymon/xymon-smart.sh
index f951158..7c10db5 100755
--- a/abs/core/xymon/xymon-smart.sh
+++ b/abs/core/xymon/xymon-smart.sh
@@ -9,16 +9,29 @@ while read DISK
do
DISKDEV=`ls -l $DISK | awk -F/ '{print $NF}'`
- #check if disk is removable
- RM=0
- RM=`cat /sys/block/$DISKDEV/removable`
- if test $RM -ne 0
+ #check if device is optical
+ if [[ $DISKDEV == "sr"* ]]
then
continue
fi
- DRES=`sudo /usr/sbin/smartctl -H -n standby $DISK`
+ #check if device is mounted
+ if ! mount | grep -q /dev/$DISKDEV
+ then
+ continue
+ fi
+
+ DRES=`sudo /usr/bin/smartctl -H -n standby $DISK`
DCODE=$?
+
+ #check if SMART is disabled and enable
+ if [[ $DRES == *"SMART Disabled. Use option -s with argument 'on'"* ]]
+ then
+ sudo /usr/bin/smartctl -s on $DISK
+ DRES=`sudo /usr/bin/smartctl -H -n standby $DISK`
+ DCODE=$?
+ fi
+
DSTBY=$(( $DCODE & 2 ))
DFAIL=$(( $DCODE & 8 ))
DWARN=$(( $DCODE & 32 ))