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