Comment and small fixes
This commit is contained in:
parent
fcf945748b
commit
cbf0d8afb0
|
@ -3,22 +3,24 @@
|
||||||
# NOTE: Must be run as root, so you probably need to setup sudo for this.
|
# 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
|
if test -f /tmp/dres; then rm -f /tmp/dres; fi
|
||||||
|
if test -f /tmp/dscan; then rm -f /tmp/dscan; fi
|
||||||
|
|
||||||
|
# Get the list of all available devices
|
||||||
smartctl --scan > /tmp/dscan
|
smartctl --scan > /tmp/dscan
|
||||||
|
|
||||||
# MODIFY below to match your setup - the "scsi-SATA" is pretty generic, but you
|
while IFS= read -r LINE; do
|
||||||
# can add more disks if you like. E.g. I have a USB disk permanently plugged in.
|
## Get device and type
|
||||||
|
|
||||||
while read LINE
|
|
||||||
do
|
|
||||||
DISK=$(echo "${LINE}" | cut -d" " -f1)
|
DISK=$(echo "${LINE}" | cut -d" " -f1)
|
||||||
TYPE=$(echo "${LINE}" | cut -d" " -f3)
|
TYPE=$(echo "${LINE}" | cut -d" " -f3)
|
||||||
|
|
||||||
|
## Get SMART Health Status and return code
|
||||||
DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}")
|
DRES=$(/usr/sbin/smartctl -H -d "${TYPE}" -n standby "${DISK}")
|
||||||
DCODE=$?
|
DCODE=$?
|
||||||
DSTBY=$(( DCODE & 2 ))
|
DSTBY=$(( DCODE & 2 ))
|
||||||
DFAIL=$(( DCODE & 8 ))
|
DFAIL=$(( DCODE & 8 ))
|
||||||
DWARN=$(( DCODE & 32 ))
|
DWARN=$(( DCODE & 32 ))
|
||||||
|
|
||||||
|
## Give a weight to each to color to easily get the page status
|
||||||
if test $DSTBY -ne 0
|
if test $DSTBY -ne 0
|
||||||
then
|
then
|
||||||
COLOR="4&clear"
|
COLOR="4&clear"
|
||||||
|
@ -36,15 +38,16 @@ do
|
||||||
|
|
||||||
echo "${COLOR} $DISK ${TYPE}" | cut -c2- >>/tmp/dres
|
echo "${COLOR} $DISK ${TYPE}" | cut -c2- >>/tmp/dres
|
||||||
echo "" >>/tmp/dres
|
echo "" >>/tmp/dres
|
||||||
echo "$DRES" | egrep -v "^smartctl|^Copyright|^$|^===" >>/tmp/dres
|
echo "$DRES" | grep -v -E "^smartctl|^Copyright|^$|^===" >>/tmp/dres
|
||||||
echo "------------------------------------------------------------" >>/tmp/dres
|
echo "------------------------------------------------------------" >>/tmp/dres
|
||||||
echo "" >>/tmp/dres
|
echo "" >>/tmp/dres
|
||||||
echo "" >>/tmp/dres
|
echo "" >>/tmp/dres
|
||||||
done < /tmp/dscan >/tmp/dcheck
|
done < /tmp/dscan >/tmp/dcheck
|
||||||
|
|
||||||
|
# Set the global color according to the highest alert
|
||||||
COLOR=$(< /tmp/dcheck awk '{print $1}' | sort | uniq | head -1 | cut -c3-)
|
COLOR=$(< /tmp/dcheck awk '{print $1}' | sort | uniq | head -1 | cut -c3-)
|
||||||
|
|
||||||
$XYMON $XYMSRV "status ${MACHINE}.smart ${COLOR} SMART health check
|
$XYMON "${XYMSRV}" "status ${MACHINE}.smart ${COLOR} SMART health check
|
||||||
|
|
||||||
$(< /tmp/dcheck cut -c2-)
|
$(< /tmp/dcheck cut -c2-)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue