forked from evolix/ansible-roles
nagios-nrpe: Added hpsa support to check_hpraid
Also handle empty slots.
This commit is contained in:
parent
f35cbdbe30
commit
314cd2c1de
|
@ -4,7 +4,7 @@ set -euo pipefail
|
||||||
|
|
||||||
# This check_hpraid is a fork from check_cciss v0.15 written by Simone Rosa.
|
# This check_hpraid is a fork from check_cciss v0.15 written by Simone Rosa.
|
||||||
# Fork written by Evolix and for Evolix usage (Debian only).
|
# Fork written by Evolix and for Evolix usage (Debian only).
|
||||||
# Usage of old tools and drivers were removed to use only the smartpqi driver and the ssacli tool from HP.
|
# Usage of old tools and drivers were removed to use only the smartpqi or hpsa drivers and the ssacli tool from HP.
|
||||||
# Tools not used on Debian were also removed.
|
# Tools not used on Debian were also removed.
|
||||||
# Linting tool shellcheck was used to use a better bash coding style.
|
# Linting tool shellcheck was used to use a better bash coding style.
|
||||||
# Upstream at:
|
# Upstream at:
|
||||||
|
@ -77,7 +77,7 @@ set -euo pipefail
|
||||||
# Battery/Capacitor Status: Failed (Replace Batteries/Capacitors)
|
# Battery/Capacitor Status: Failed (Replace Batteries/Capacitors)
|
||||||
|
|
||||||
PROGNAME=$(basename "$0")
|
PROGNAME=$(basename "$0")
|
||||||
NAGIOS_PLUGINS="/usr/lib/nagios/plugins/"
|
NAGIOS_PLUGINS="/usr/lib/nagios/plugins"
|
||||||
REVISION="0.16-evolix"
|
REVISION="0.16-evolix"
|
||||||
DEBUG="0"
|
DEBUG="0"
|
||||||
VERBOSE="0"
|
VERBOSE="0"
|
||||||
|
@ -138,16 +138,15 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Use smartpqi driver
|
# Check if smartpqi or hpsa driver is loaded
|
||||||
# https://manpages.debian.org/buster/manpages/smartpqi.4.en.html
|
# https://manpages.debian.org/buster/manpages/smartpqi.4.en.html
|
||||||
if [ -d /sys/bus/pci/drivers/smartpqi ]; then
|
if [ -d /sys/bus/pci/drivers/smartpqi ] || [ -d /sys/bus/pci/drivers/hpsa ]; then
|
||||||
DRIVER="/sys/bus/pci/drivers/smartpqi"
|
|
||||||
driverPresent='YES.'
|
driverPresent='YES.'
|
||||||
else
|
else
|
||||||
driverPresent='No!'
|
driverPresent='No!'
|
||||||
fi
|
fi
|
||||||
if [ "$DEBUG" = "1" ]; then
|
if [ "$DEBUG" = "1" ]; then
|
||||||
echo "### Check if \"HP Smart Array\" ($DRIVER) is present >>>\n${driverPresent}\n"
|
echo "### Check if \"HP Smart Array\" driver is present >>>\n${driverPresent}\n"
|
||||||
fi
|
fi
|
||||||
if [[ "$driverPresent" == "No!" ]]; then
|
if [[ "$driverPresent" == "No!" ]]; then
|
||||||
echo "RAID UNKNOWN - HP Smart Array not found"
|
echo "RAID UNKNOWN - HP Smart Array not found"
|
||||||
|
@ -193,12 +192,18 @@ fi
|
||||||
|
|
||||||
for slot in $slots; do
|
for slot in $slots; do
|
||||||
# Get "logicaldrive" for slot
|
# Get "logicaldrive" for slot
|
||||||
|
set +e
|
||||||
check2b=$(sudo -u root "$ssacli" controller slot="$slot" logicaldrive all show 2>&1)
|
check2b=$(sudo -u root "$ssacli" controller slot="$slot" logicaldrive all show 2>&1)
|
||||||
status=$?
|
status=$?
|
||||||
if test ${status} -ne 0; then
|
if test ${status} -ne 0; then
|
||||||
|
# Skip empty slots
|
||||||
|
if grep -q "The specified device does not have any logical drives." <<< "$check2b"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
echo "RAID UNKNOWN - $ssacli did not execute properly : ""${check2b}"
|
echo "RAID UNKNOWN - $ssacli did not execute properly : ""${check2b}"
|
||||||
exit "$STATE_UNKNOWN"
|
exit "$STATE_UNKNOWN"
|
||||||
fi
|
fi
|
||||||
|
set -e
|
||||||
check2=${check2:-}
|
check2=${check2:-}
|
||||||
check2="$check2$check2b"
|
check2="$check2$check2b"
|
||||||
if [ "$DEBUG" = "1" ]; then
|
if [ "$DEBUG" = "1" ]; then
|
||||||
|
|
Loading…
Reference in a new issue