summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/xymon-smart.sh
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2016-01-29 17:29:28 (GMT)
committerBritney Fransen <brfransen@gmail.com>2016-01-29 17:29:28 (GMT)
commitd28fa9756f4898ddccef11d97da7d40fc634f7bd (patch)
treecb2229f31345f5e936d292a2a412a663918d0660 /abs/core/xymon/xymon-smart.sh
parent157bdaa9b865723785c1047324843af8468849ea (diff)
downloadlinhes_pkgbuild-d28fa9756f4898ddccef11d97da7d40fc634f7bd.zip
linhes_pkgbuild-d28fa9756f4898ddccef11d97da7d40fc634f7bd.tar.gz
linhes_pkgbuild-d28fa9756f4898ddccef11d97da7d40fc634f7bd.tar.bz2
xymon: xymon-smart.sh: check for optical and mounted
check if SMART is disabled and enable
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 ))