diff options
author | Britney Fransen <brfransen@gmail.com> | 2015-03-05 01:10:11 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2015-03-05 01:10:11 (GMT) |
commit | 4fa58e575df074c999db5cbc13a2488131597fcc (patch) | |
tree | 8c020858d8b9516b4f6e881cf8310ed8a489350e /abs/core/xymon/xymon-hddtemp.sh | |
parent | 53d9a174f4f05c94c0fe392a83deb310095310b1 (diff) | |
download | linhes_pkgbuild-4fa58e575df074c999db5cbc13a2488131597fcc.zip linhes_pkgbuild-4fa58e575df074c999db5cbc13a2488131597fcc.tar.gz linhes_pkgbuild-4fa58e575df074c999db5cbc13a2488131597fcc.tar.bz2 |
xymon: add hddtemp module
Diffstat (limited to 'abs/core/xymon/xymon-hddtemp.sh')
-rwxr-xr-x | abs/core/xymon/xymon-hddtemp.sh | 50 |
1 files changed, 50 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..6961919 --- /dev/null +++ b/abs/core/xymon/xymon-hddtemp.sh @@ -0,0 +1,50 @@ +#!/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}'` + + #check if disk is removable + RM=0 + RM=`cat /sys/block/$DISKDEV/removable` + if test $RM -ne 0 + then + continue + fi + + hddtemp=`sudo smartctl -A $DISK | grep Temperature_Celsius | awk '{print $10}'` + + TEMP=": $hddtemp" + if [[ $hddtemp == "" ]] + then + TEMP="- No Temp Sensor Found" + COLOR="4&clear" + elif test $hddtemp -gt 50 + then + COLOR="1&red" + elif test $hddtemp -ge 45 + 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 °C) + +`cat /tmp/hddcheck | cut -c2-` +" + +rm -f /tmp/hddcheck + +exit 0 |