check_qnap_health: Update to latest version
This commit is contained in:
parent
685fadac6c
commit
f9ed6fdc3d
|
@ -6,6 +6,7 @@
|
||||||
############################# finetuning by vitamin.b@mailbox.org
|
############################# finetuning by vitamin.b@mailbox.org
|
||||||
############################# with code by Tom Lesniak and Hugo Geijteman
|
############################# with code by Tom Lesniak and Hugo Geijteman
|
||||||
############################# with code by Carsten Koebke
|
############################# with code by Carsten Koebke
|
||||||
|
############################# with code by sgruber
|
||||||
#
|
#
|
||||||
# copyright (c) 2008 Shahid Iqbal
|
# copyright (c) 2008 Shahid Iqbal
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -596,6 +597,7 @@ elif [ "$strPart" == "lunstatus" ]; then
|
||||||
PERFOUTPUT=""
|
PERFOUTPUT=""
|
||||||
WARNING=0
|
WARNING=0
|
||||||
CRITICAL=0
|
CRITICAL=0
|
||||||
|
lunDISABLEDCOUNT=0
|
||||||
lun=1
|
lun=1
|
||||||
lunCOUNT="$(_snmpwalk .1.3.6.1.4.1.24681.1.4.1.1.2.1.10.2.1.2 | wc -l)"
|
lunCOUNT="$(_snmpwalk .1.3.6.1.4.1.24681.1.4.1.1.2.1.10.2.1.2 | wc -l)"
|
||||||
|
|
||||||
|
@ -609,6 +611,7 @@ elif [ "$strPart" == "lunstatus" ]; then
|
||||||
lunSTAT="OK($lun_Status)"
|
lunSTAT="OK($lun_Status)"
|
||||||
else
|
else
|
||||||
lunSTAT="CRITICAL($lun_Status)"
|
lunSTAT="CRITICAL($lun_Status)"
|
||||||
|
lunDISABLEDCOUNT=$((lunDISABLEDCOUNT+1))
|
||||||
CRITICAL=1
|
CRITICAL=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -646,7 +649,10 @@ elif [ "$strPart" == "lunstatus" ]; then
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$ALLOUTPUT" ]; then
|
if [ -z "$ALLOUTPUT" ]; then
|
||||||
ALLOUTPUT="OK: All luns are fine."
|
ALLOUTPUT="OK: All $lunCOUNT luns are fine."
|
||||||
|
if [ $lunDISABLEDCOUNT -ne 0 ]; then
|
||||||
|
ALLOUTPUT="CRITICAL: $lunDISABLEDCOUNT of $lunCOUNT luns are disabled."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo "$ALLOUTPUT| $PERFOUTPUT"
|
echo "$ALLOUTPUT| $PERFOUTPUT"
|
||||||
|
|
||||||
|
@ -672,68 +678,68 @@ elif [ "$strPart" == "volstatus" ]; then
|
||||||
|
|
||||||
while [ "$VOL" -le "$VOLCOUNT" ]; do
|
while [ "$VOL" -le "$VOLCOUNT" ]; do
|
||||||
Vol_Status="$(_snmpgetval ".1.3.6.1.4.1.24681.1.2.17.1.6.$VOL" | sed 's/^"\(.*\).$/\1/')"
|
Vol_Status="$(_snmpgetval ".1.3.6.1.4.1.24681.1.2.17.1.6.$VOL" | sed 's/^"\(.*\).$/\1/')"
|
||||||
|
if [ "$Vol_Status" != "No Such Instance currently exists at this OID" ]; then
|
||||||
|
if [ "$Vol_Status" == "Ready" ]; then
|
||||||
|
VOLSTAT="OK: $Vol_Status"
|
||||||
|
elif [ "$Vol_Status" == "Rebuilding..." ]; then
|
||||||
|
VOLSTAT="WARNING: $Vol_Status"
|
||||||
|
WARNING=1
|
||||||
|
else
|
||||||
|
VOLSTAT="CRITICAL: $Vol_Status"
|
||||||
|
CRITICAL=1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$Vol_Status" == "Ready" ]; then
|
volCpctStr="$(_snmpget ".1.3.6.1.4.1.24681.1.2.17.1.4.$VOL")"
|
||||||
VOLSTAT="OK: $Vol_Status"
|
volFreeStr="$(_snmpget ".1.3.6.1.4.1.24681.1.2.17.1.5.$VOL")"
|
||||||
elif [ "$Vol_Status" == "Rebuilding..." ]; then
|
|
||||||
VOLSTAT="WARNING: $Vol_Status"
|
volCpctSize="$(echo "$volCpctStr" | awk '{print $4}' | sed 's/.\(.*\)/\1/')"
|
||||||
WARNING=1
|
volFreeSize="$(echo "$volFreeStr" | awk '{print $4}' | sed 's/.\(.*\)/\1/')"
|
||||||
else
|
volCpctUnit="$(echo "$volCpctStr" | awk '{print $5}' | sed 's/.*\(.B\).*/\1/')"
|
||||||
VOLSTAT="CRITICAL: $Vol_Status"
|
volFreeUnit="$(echo "$volFreeStr" | awk '{print $5}' | sed 's/.*\(.B\).*/\1/')"
|
||||||
CRITICAL=1
|
|
||||||
|
volCpctExp="$(_get_exp "$volCpctUnit")"
|
||||||
|
volFreeExp="$(_get_exp "$volFreeUnit")"
|
||||||
|
|
||||||
|
volCpct="$(echo "scale=0; $volCpctSize*(2^$volCpctExp)" | bc -l)"
|
||||||
|
volFree="$(echo "scale=0; $volFreeSize*(2^$volFreeExp)" | bc -l)"
|
||||||
|
volUsed="$(echo "scale=0; $volCpct-$volFree" | bc -l)"
|
||||||
|
|
||||||
|
volFreePct="$(echo "scale=0; $volFree*100/$volCpct" | bc -l)"
|
||||||
|
volUsedPct="$(echo "scale=0; $volUsed*100/$volCpct" | bc -l)"
|
||||||
|
|
||||||
|
volCpctH="$(echo "scale=2; $volCpct/(2^$volCpctExp)" | bc -l)"
|
||||||
|
volFreeH="$(echo "scale=2; $volFree/(2^$volFreeExp)" | bc -l)"
|
||||||
|
volUsedH="$(echo "scale=2; $volUsed/(2^$volFreeExp)" | bc -l)"
|
||||||
|
|
||||||
|
if [ "${inhuman:-0}" -eq 1 ]; then
|
||||||
|
volCpctF="$volCpct"
|
||||||
|
volFreeF="$volFree"
|
||||||
|
volUsedF="$volUsed"
|
||||||
|
else
|
||||||
|
volCpctF="$volCpctH $volCpctUnit"
|
||||||
|
volFreeF="$volFreeH $volFreeUnit"
|
||||||
|
volUsedF="$volUsedH $volFreeUnit"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$volFreePct" -le "$strCritical" ]; then
|
||||||
|
volFreePct="CRITICAL: $volFreePct"
|
||||||
|
CRITICAL=1
|
||||||
|
elif [ "$volFreePct" -le "$strWarning" ]; then
|
||||||
|
volFreePct="WARNING: $volFreePct"
|
||||||
|
WARNING=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ALLOUTPUT="${ALLOUTPUT}Volume #$VOL: $VOLSTAT, Total Size (bytes): $volCpctF, Free: $volFreeF (${volFreePct}%)"
|
||||||
|
if [ "$VOL" -lt "$VOLCOUNT" ]; then
|
||||||
|
ALLOUTPUT="${ALLOUTPUT}, "
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Performance Data
|
||||||
|
if [ $VOL -gt 1 ]; then
|
||||||
|
PERFOUTPUT="$PERFOUTPUT "
|
||||||
|
fi
|
||||||
|
PERFOUTPUT="${PERFOUTPUT}FreeSize_Volume-$VOL=${volFreePct}%;$strWarning;$strCritical;0;100"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
volCpctStr="$(_snmpget ".1.3.6.1.4.1.24681.1.2.17.1.4.$VOL")"
|
|
||||||
volFreeStr="$(_snmpget ".1.3.6.1.4.1.24681.1.2.17.1.5.$VOL")"
|
|
||||||
|
|
||||||
volCpctSize="$(echo "$volCpctStr" | awk '{print $4}' | sed 's/.\(.*\)/\1/')"
|
|
||||||
volFreeSize="$(echo "$volFreeStr" | awk '{print $4}' | sed 's/.\(.*\)/\1/')"
|
|
||||||
volCpctUnit="$(echo "$volCpctStr" | awk '{print $5}' | sed 's/.*\(.B\).*/\1/')"
|
|
||||||
volFreeUnit="$(echo "$volFreeStr" | awk '{print $5}' | sed 's/.*\(.B\).*/\1/')"
|
|
||||||
|
|
||||||
volCpctExp="$(_get_exp "$volCpctUnit")"
|
|
||||||
volFreeExp="$(_get_exp "$volFreeUnit")"
|
|
||||||
|
|
||||||
volCpct="$(echo "scale=0; $volCpctSize*(2^$volCpctExp)" | bc -l)"
|
|
||||||
volFree="$(echo "scale=0; $volFreeSize*(2^$volFreeExp)" | bc -l)"
|
|
||||||
volUsed="$(echo "scale=0; $volCpct-$volFree" | bc -l)"
|
|
||||||
|
|
||||||
volFreePct="$(echo "scale=0; $volFree*100/$volCpct" | bc -l)"
|
|
||||||
volUsedPct="$(echo "scale=0; $volUsed*100/$volCpct" | bc -l)"
|
|
||||||
|
|
||||||
volCpctH="$(echo "scale=2; $volCpct/(2^$volCpctExp)" | bc -l)"
|
|
||||||
volFreeH="$(echo "scale=2; $volFree/(2^$volFreeExp)" | bc -l)"
|
|
||||||
volUsedH="$(echo "scale=2; $volUsed/(2^$volFreeExp)" | bc -l)"
|
|
||||||
|
|
||||||
if [ "${inhuman:-0}" -eq 1 ]; then
|
|
||||||
volCpctF="$volCpct"
|
|
||||||
volFreeF="$volFree"
|
|
||||||
volUsedF="$volUsed"
|
|
||||||
else
|
|
||||||
volCpctF="$volCpctH $volCpctUnit"
|
|
||||||
volFreeF="$volFreeH $volFreeUnit"
|
|
||||||
volUsedF="$volUsedH $volFreeUnit"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$volFreePct" -le "$strCritical" ]; then
|
|
||||||
volFreePct="CRITICAL: $volFreePct"
|
|
||||||
CRITICAL=1
|
|
||||||
elif [ "$volFreePct" -le "$strWarning" ]; then
|
|
||||||
volFreePct="WARNING: $volFreePct"
|
|
||||||
WARNING=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ALLOUTPUT="${ALLOUTPUT}Volume #$VOL: $VOLSTAT, Total Size (bytes): $volCpctF, Free: $volFreeF (${volFreePct}%)"
|
|
||||||
if [ "$VOL" -lt "$VOLCOUNT" ]; then
|
|
||||||
ALLOUTPUT="${ALLOUTPUT}, "
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Performance Data
|
|
||||||
if [ $VOL -gt 1 ]; then
|
|
||||||
PERFOUTPUT="$PERFOUTPUT "
|
|
||||||
fi
|
|
||||||
PERFOUTPUT="${PERFOUTPUT}FreeSize_Volume-$VOL=${volFreePct}%;$strWarning;$strCritical;0;100"
|
|
||||||
|
|
||||||
VOL="`expr $VOL + 1`"
|
VOL="`expr $VOL + 1`"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue