Init smart plugin from xymon.com
https://www.xymon.com/xymon-cgi/viewconf.sh?smart
This commit is contained in:
parent
3c6e0ad5ed
commit
681d1ee0c3
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
|
||||
# NOTE: Must be run as root, so you probably need to setup sudo for this.
|
||||
|
||||
# Thanks to xymon.com − https://www.xymon.com/xymon-cgi/viewconf.sh?smart
|
||||
|
||||
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-SATA_* /dev/disk/by-id/usb-WD* | grep -v -- -part | sort |
|
||||
while read DISK
|
||||
do
|
||||
DRES=`/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"
|
||||
|
||||
echo "${COLOR} $DISK" | 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
|
||||
|
Loading…
Reference in New Issue