summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/xymon-smart.sh
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2015-02-20 20:11:18 (GMT)
committerBritney Fransen <brfransen@gmail.com>2015-02-20 20:11:18 (GMT)
commit53d9a174f4f05c94c0fe392a83deb310095310b1 (patch)
tree3805c7057bff77acedd900fb1eae8a62db1b01cc /abs/core/xymon/xymon-smart.sh
parent6fde8cd5e74f0840e01988e743464fe91c0a28f8 (diff)
downloadlinhes_pkgbuild-53d9a174f4f05c94c0fe392a83deb310095310b1.zip
linhes_pkgbuild-53d9a174f4f05c94c0fe392a83deb310095310b1.tar.gz
linhes_pkgbuild-53d9a174f4f05c94c0fe392a83deb310095310b1.tar.bz2
xymon: add smart monitor
hobbit-myth-orphan.sh: add some help text
Diffstat (limited to 'abs/core/xymon/xymon-smart.sh')
-rwxr-xr-xabs/core/xymon/xymon-smart.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/abs/core/xymon/xymon-smart.sh b/abs/core/xymon/xymon-smart.sh
new file mode 100755
index 0000000..1ad3cc7
--- /dev/null
+++ b/abs/core/xymon/xymon-smart.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# NOTE: Must be run as root, so you probably need to setup sudo for this.
+
+if test -f /tmp/dres; then rm -f /tmp/dres; fi
+
+# MODIFY below to match your setup - the "scsi-SATA" is pretty generic, but you
+# can add more disks if you like. E.g. I have a USB disk permanently plugged in.
+
+ls /dev/disk/by-id/scsi-* /dev/disk/by-id/ata-* /dev/disk/by-id/usb-* | grep -v -- -part | sort |
+while read DISK
+do
+ DISKDEV=`ls -l $DISK | awk -F/ '{print $NF}'`
+
+ #check if disk is removable
+ RM=`cat /sys/block/$DISKDEV/removable`
+ if test $RM -ne 0
+ then
+ continue
+ fi
+
+ DRES=`sudo /usr/sbin/smartctl -H -n standby $DISK`
+ DCODE=$?
+ DSTBY=$(( $DCODE & 2 ))
+ DFAIL=$(( $DCODE & 8 ))
+ DWARN=$(( $DCODE & 32 ))
+
+ if test $DSTBY -ne 0
+ then
+ COLOR="4&clear"
+ elif test $DFAIL -ne 0
+ then
+ COLOR="1&red"
+ elif test $DWARN -ne 0
+ then
+ COLOR="2&yellow"
+ else
+ COLOR="3&green"
+ fi
+
+ echo "${COLOR} $DISK (/dev/$DISKDEV)"
+
+ echo "${COLOR} $DISK (/dev/$DISKDEV)" | cut -c2- >>/tmp/dres
+ echo "" >>/tmp/dres
+ echo "$DRES" | egrep -v "^smartctl|^Copyright|^$|^===" >>/tmp/dres
+ echo "-----------------------------------------------------------------------------" >>/tmp/dres
+ echo "" >>/tmp/dres
+ echo "" >>/tmp/dres
+done >/tmp/dcheck
+
+COLOR=`cat /tmp/dcheck | awk '{print $1}' | sort | uniq | head -1 | cut -c3-`
+
+$XYMON $XYMSRV "status ${MACHINE}.smart ${COLOR} SMART Health Check
+
+`cat /tmp/dcheck | cut -c2-`
+
+============================== Detailed status ==============================
+
+`cat /tmp/dres`
+"
+
+rm -f /tmp/dres /tmp/dcheck
+
+exit 0
+