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.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/abs/core/xymon/xymon-hddtemp.sh b/abs/core/xymon/xymon-hddtemp.sh
new file mode 100755
index 0000000..7084abc
--- /dev/null
+++ b/abs/core/xymon/xymon-hddtemp.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# NOTE: Must be run as root, so you probably need to setup sudo for this.
+
+ls /dev/disk/by-id/* | grep -ve '-part' -ve '/wwn-' |
+while read DISK
+do
+ DISKDEV=`ls -l $DISK | awk -F/ '{print $NF}'`
+ DISKNAME=`echo $DISK | awk -F/ '{print $5}' | tr ":" "_"`
+
+ #check if device is optical
+ if [[ $DISKDEV == "sr"* ]]
+ then
+ continue
+ fi
+
+ #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 == "" ]]
+ then
+ TEMP="- No Temp Sensor Found"
+ COLOR="4&clear"
+ elif test $hddtemp -gt 55
+ then
+ COLOR="1&red"
+ elif test $hddtemp -ge 50
+ then
+ COLOR="2&yellow"
+ else
+ COLOR="3&green"
+ fi
+
+ echo "${COLOR} $DISKNAME $TEMP"
+
+done > /tmp/hddcheck
+
+COLOR=`cat /tmp/hddcheck | awk '{print $1}' | sort | uniq | head -1 | cut -c3-`
+
+# Report status to Xymon Server
+$XYMON $XYMSRV "status ${MACHINE}.hddtemp ${COLOR} Hard Drive Temperatures (in &degC)
+
+`cat /tmp/hddcheck | cut -c2-`
+"
+
+rm -f /tmp/hddcheck
+
+exit 0