check_qnap_health: Update to 1.01

This commit is contained in:
Jan Wagner 2021-07-21 15:03:06 +02:00
parent 088dc0d337
commit ab5f0b8c7f
2 changed files with 16 additions and 16 deletions

View file

@ -19,7 +19,7 @@
# #
# contact the author directly for more information at: matthias@xcontrol.de # contact the author directly for more information at: matthias@xcontrol.de
########################################################################################## ##########################################################################################
plgVer=1.00 plgVer=1.01
usage() { usage() {
echo echo
@ -52,7 +52,7 @@ usage() {
echo " -x|--privprotocol - privacy protocol (DES|AES)" echo " -x|--privprotocol - privacy protocol (DES|AES)"
echo " -X|--privpassphrase - privacy protocol pass phrase" echo " -X|--privpassphrase - privacy protocol pass phrase"
echo echo
echo "Parts are: status, sysinfo, systemuptime, temp, cpu, cputemp, freeram, iops, latency, powerstatus, fans, diskused, hdstatus, hdtemp, lunstatus (for iSCSI luns), volstatus (Raid Volume Status)" echo "Parts are: status, sysinfo, systemuptime, temp, cpu, cputemp, usedram, iops, latency, powerstatus, fans, diskused, hdstatus, hdtemp, lunstatus (for iSCSI luns), volstatus (Raid Volume Status)"
echo echo
echo "volstatus & lunstatus checks all vols/luns and vols/lun space; powerstatus checks power supply" echo "volstatus & lunstatus checks all vols/luns and vols/lun space; powerstatus checks power supply"
echo "<#> is 1-8 for hd, 1-5 for vol" echo "<#> is 1-8 for hd, 1-5 for vol"
@ -70,7 +70,7 @@ usage() {
echo " * awk" echo " * awk"
echo " * snmpget" echo " * snmpget"
echo " * snmpwalk" echo " * snmpwalk"
exit $EXIT_UNKOWN exit $EXIT_UNKNOWN
} }
# Default values # Default values
@ -116,12 +116,12 @@ fi
PARSED_OPTIONS=$(getopt -n "$0" -o V:H:C:p:hw:c:t:l:u:a:A:x:X:P: --long "hostname:,community:,part:,warning:,critical:,timeout:,level:,user:,authprotocol:,authpassphrase:,privprotocol:,privpassphrase:,port:,help" -- "$@") PARSED_OPTIONS=$(getopt -n "$0" -o V:H:C:p:hw:c:t:l:u:a:A:x:X:P: --long "hostname:,community:,part:,warning:,critical:,timeout:,level:,user:,authprotocol:,authpassphrase:,privprotocol:,privpassphrase:,port:,help" -- "$@")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
usage usage
exit $EXIT_UNKOWN exit $EXIT_UNKNOWN
fi fi
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
usage usage
exit $EXIT_UNKOWN exit $EXIT_UNKNOWN
fi fi
eval set -- "$PARSED_OPTIONS" eval set -- "$PARSED_OPTIONS"
@ -399,7 +399,7 @@ elif [ "$strPart" == "cputemp" ]; then
fi fi
# Free RAM--------------------------------------------------------------------------------------------------------------------------------------- # Free RAM---------------------------------------------------------------------------------------------------------------------------------------
elif [ "$strPart" == "freeram" ]; then elif [ "$strPart" == "usedram" ]; then
totalMemStr="$(_snmpgetval 1.3.6.1.4.1.24681.1.2.2.0)" totalMemStr="$(_snmpgetval 1.3.6.1.4.1.24681.1.2.2.0)"
freeMemStr="$(_snmpgetval 1.3.6.1.4.1.24681.1.2.3.0)" freeMemStr="$(_snmpgetval 1.3.6.1.4.1.24681.1.2.3.0)"
@ -431,7 +431,7 @@ elif [ "$strPart" == "freeram" ]; then
usedMemF="$usedMemH$freeMemUnit" usedMemF="$usedMemH$freeMemUnit"
fi fi
OUTPUT="Total:$totalMemF - Used:$usedMemF - Free:$freeMemF = $percMem%|Memory usage=$percMem%;$strWarning;$strCritical;0;100" OUTPUT="Total:$totalMemF - Used:$usedMemF - Free:$freeMemF|Memory usage=$percMem%;$strWarning;$strCritical;0;100"
if [ $percMem -ge $strCritical ]; then if [ $percMem -ge $strCritical ]; then
echo "CRITICAL: $OUTPUT" echo "CRITICAL: $OUTPUT"
@ -461,7 +461,7 @@ elif [ "$strPart" == "temp" ]; then
fi fi
# Disk IOPS ---------------------------------------------------------------------------------------------------------------------------------------------- # Disk IOPS ----------------------------------------------------------------------------------------------------------------------------------------------
elif [ "$strpart" == "iops" ]; then elif [ "$strPart" == "iops" ]; then
IOPS=$(_snmpgetval 1.3.6.1.4.1.24681.1.4.1.11.5.6.2.1.3.1 | sed -E 's/"|\s%//g') IOPS=$(_snmpgetval 1.3.6.1.4.1.24681.1.4.1.11.5.6.2.1.3.1 | sed -E 's/"|\s%//g')
OUTPUT="IOPS="$IOPS"|IOPS="$IOPS";$strWarning;$strCritical;0;100" OUTPUT="IOPS="$IOPS"|IOPS="$IOPS";$strWarning;$strCritical;0;100"
@ -478,7 +478,7 @@ elif [ "$strpart" == "iops" ]; then
fi fi
# Disk Latency ---------------------------------------------------------------------------------------------------------------------------------------------- # Disk Latency ----------------------------------------------------------------------------------------------------------------------------------------------
elif [ "$strpart" == "latency" ]; then elif [ "$strPart" == "latency" ]; then
LATENCY=$(_snmpgetval 1.3.6.1.4.1.24681.1.4.1.11.5.6.2.1.4.1 | sed -E 's/"|\s%//g') LATENCY=$(_snmpgetval 1.3.6.1.4.1.24681.1.4.1.11.5.6.2.1.4.1 | sed -E 's/"|\s%//g')
OUTPUT="Latency="$LATENCY"|Latency="$LATENCY";$strWarning;$strCritical;0;100" OUTPUT="Latency="$LATENCY"|Latency="$LATENCY";$strWarning;$strCritical;0;100"
@ -506,13 +506,13 @@ elif [[ "$strPart" == hdtemp ]]; then
for (( c=1; c<=$hdnum; c++ )) for (( c=1; c<=$hdnum; c++ ))
do do
TEMPHD="$(_snmpgetval "1.3.6.1.4.1.24681.1.2.11.1.3.$c" | sed -E 's/"([0-9.]+) ?C.*/\1/')" TEMPHD="$(_snmpgetval "1.3.6.1.4.1.24681.1.2.11.1.3.$c" | sed -E 's/"([0-9.]+) ?C.*/\1/')"
if [[ ! $TEMPHD =~ ^-?[0-9]+$ ]]; then
if [ "$(echo "$TEMPHD" | sed -E 's/[0-9.]+//g')" != "" ]; then if [ -n "$UnknownStr" ]; then
if [ -n "$UnknownStr"]; then
UnknownStr="${UnknownStr},HDD${c}" UnknownStr="${UnknownStr},HDD${c}"
else else
UnknownStr="UNKNOWN: HD${c}" UnknownStr="UNKNOWN: HD${c}"
fi fi
continue
fi fi
if [ $TEMPHD -ge $strCritical ]; then if [ $TEMPHD -ge $strCritical ]; then
if [ -n "$CriticalStr" ]; then if [ -n "$CriticalStr" ]; then
@ -548,7 +548,7 @@ elif [[ "$strPart" == hdtemp ]]; then
OUTPUT="$OUTPUT $WarningStr" OUTPUT="$OUTPUT $WarningStr"
fi fi
if [ -n "$UnknownStr" ];then if [ -n "$UnknownStr" ];then
if [ ! $EXIT -eq 1 -o ! $EXIT -eq 2 ];then if [ ! $EXIT -eq 1 -a ! $EXIT -eq 2 ];then
EXIT=$EXIT_UNKNOWN EXIT=$EXIT_UNKNOWN
fi fi
OUTPUT="$OUTPUT $UnknownStr" OUTPUT="$OUTPUT $UnknownStr"
@ -645,7 +645,7 @@ elif [ "$strPart" == "lunstatus" ]; then
unset lunUsedPctStr unset lunUsedPctStr
done done
if [ -z $ALLOUTPUT ]; then if [ -z "$ALLOUTPUT" ]; then
ALLOUTPUT="OK: All luns are fine." ALLOUTPUT="OK: All luns are fine."
fi fi
echo "$ALLOUTPUT| $PERFOUTPUT" echo "$ALLOUTPUT| $PERFOUTPUT"
@ -845,7 +845,7 @@ elif [ "$strPart" == "systemuptime" ]; then
if [ -z $sysuptime -o -z $netuptime ]; then if [ -z $sysuptime -o -z $netuptime ]; then
OUTPUT="UNKOWN: Could not get uptime information!" OUTPUT="UNKOWN: Could not get uptime information!"
EXIT=$EXIT_UNKOWN EXIT=$EXIT_UNKNOWN
fi fi
if [ "$sysuptime" -le "$strCritical" ]; then if [ "$sysuptime" -le "$strCritical" ]; then
OUTPUT="CRITICAL: System up since $(date -d @$(( $(date +%s) - $sysuptime )))" OUTPUT="CRITICAL: System up since $(date -d @$(( $(date +%s) - $sysuptime )))"

View file

@ -3,4 +3,4 @@ Watch: https://raw.githubusercontent.com/Mikesch-mp/qnap_health/master/qnap_heal
Uploaders: Jan Wagner <waja@cyconet.org> Uploaders: Jan Wagner <waja@cyconet.org>
Description: plugin to check NAS QNAP. Description: plugin to check NAS QNAP.
Recommends: bc, gawk | mawk, snmp Recommends: bc, gawk | mawk, snmp
Version: 1.00 Version: 1.01