summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/xymon-hddtemp.sh
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2016-01-29 19:29:24 (GMT)
committerBritney Fransen <brfransen@gmail.com>2016-01-29 19:29:24 (GMT)
commit0873cf04612494e0d385b2033f4287fa69931a4f (patch)
tree1fcc033b02a2008333c4a6a84945b291ab9c0b64 /abs/core/xymon/xymon-hddtemp.sh
parent2204ce656276d6b9776d2c99882bfe093be3808b (diff)
downloadlinhes_pkgbuild-0873cf04612494e0d385b2033f4287fa69931a4f.zip
linhes_pkgbuild-0873cf04612494e0d385b2033f4287fa69931a4f.tar.gz
linhes_pkgbuild-0873cf04612494e0d385b2033f4287fa69931a4f.tar.bz2
xymon: xymon-hddtemp.sh: check for optical and mounted
check if SMART is enabled
Diffstat (limited to 'abs/core/xymon/xymon-hddtemp.sh')
-rwxr-xr-xabs/core/xymon/xymon-hddtemp.sh22
1 files changed, 17 insertions, 5 deletions
diff --git a/abs/core/xymon/xymon-hddtemp.sh b/abs/core/xymon/xymon-hddtemp.sh
index 6c0f109..7084abc 100755
--- a/abs/core/xymon/xymon-hddtemp.sh
+++ b/abs/core/xymon/xymon-hddtemp.sh
@@ -8,15 +8,27 @@ do
DISKDEV=`ls -l $DISK | awk -F/ '{print $NF}'`
DISKNAME=`echo $DISK | awk -F/ '{print $5}' | tr ":" "_"`
- #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
- hddtemp=`sudo smartctl -A $DISK | grep Temperature_Celsius | awk '{print $10}'`
+ #check if device is mounted
+ if ! mount | grep -q /dev/$DISKDEV
+ then
+ continue
+ fi
+
+ #check if SMART is disabled and enable
+ DRES=`sudo /usr/bin/smartctl -A $DISK`
+ if [[ $DRES == *"SMART Disabled. Use option -s with argument 'on'"* ]]
+ then
+ sudo /usr/bin/smartctl -s on $DISK
+ DRES=`sudo /usr/bin/smartctl -A $DISK`
+ fi
+
+ hddtemp=`echo "$DRES" | grep Temperature_Celsius | awk '{print $10}'`
TEMP=": $hddtemp"
if [[ $hddtemp == "" ]]