summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/xymon-hddtemp.sh
diff options
context:
space:
mode:
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 == "" ]]