Add comment
This commit is contained in:
parent
b6c1913065
commit
8a3c0de8e4
|
@ -56,6 +56,7 @@ is_disk_support_smart() {
|
||||||
}
|
}
|
||||||
## }}}
|
## }}}
|
||||||
## Test the type of disk with smartctl {{{
|
## Test the type of disk with smartctl {{{
|
||||||
|
## Cause the scanned one might not be the one to use
|
||||||
choose_correct_type() {
|
choose_correct_type() {
|
||||||
_disk="${1}"
|
_disk="${1}"
|
||||||
_scanned_type="${2}"
|
_scanned_type="${2}"
|
||||||
|
@ -89,7 +90,7 @@ true > /tmp/dscan
|
||||||
# Get the list of all available devices
|
# Get the list of all available devices
|
||||||
smartctl --scan >> /tmp/dscan
|
smartctl --scan >> /tmp/dscan
|
||||||
|
|
||||||
# TODO: Test if the file is not empty
|
# If the file is not empty
|
||||||
if test -s /tmp/dscan; then
|
if test -s /tmp/dscan; then
|
||||||
while IFS= read -r LINE; do
|
while IFS= read -r LINE; do
|
||||||
## Get device path
|
## Get device path
|
||||||
|
@ -111,11 +112,12 @@ if test -s /tmp/dscan; then
|
||||||
DCODE=$?
|
DCODE=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Test health status
|
||||||
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
|
## According to health, give a weight to each 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"
|
||||||
|
@ -129,8 +131,10 @@ if test -s /tmp/dscan; then
|
||||||
COLOR="3&green"
|
COLOR="3&green"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## For summary
|
||||||
echo "${COLOR} $DISK ${TYPE}"
|
echo "${COLOR} $DISK ${TYPE}"
|
||||||
|
|
||||||
|
## For detailed informations
|
||||||
{
|
{
|
||||||
echo "${COLOR} $DISK ${TYPE}" | cut -c2-
|
echo "${COLOR} $DISK ${TYPE}" | cut -c2-
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -141,6 +145,7 @@ if test -s /tmp/dscan; then
|
||||||
} >> /tmp/dres
|
} >> /tmp/dres
|
||||||
done < /tmp/dscan >> /tmp/dcheck
|
done < /tmp/dscan >> /tmp/dcheck
|
||||||
|
|
||||||
|
# If the file is empty
|
||||||
else
|
else
|
||||||
echo "1&red Error while scanning devices with smartctl" >> /tmp/dcheck
|
echo "1&red Error while scanning devices with smartctl" >> /tmp/dcheck
|
||||||
fi
|
fi
|
||||||
|
@ -148,6 +153,7 @@ fi
|
||||||
# Set the global color according to the highest alert
|
# 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-)
|
||||||
|
|
||||||
|
# Send informations to Xymon server
|
||||||
$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-)
|
||||||
|
@ -157,6 +163,7 @@ $(< /tmp/dcheck cut -c2-)
|
||||||
$(cat /tmp/dres)
|
$(cat /tmp/dres)
|
||||||
"
|
"
|
||||||
|
|
||||||
|
# Clean temp files
|
||||||
rm -f -- /tmp/dres /tmp/dcheck /tmp/dscan
|
rm -f -- /tmp/dres /tmp/dcheck /tmp/dscan
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue