nagios-plugins/check_dataprotector/check_dp_pool

61 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright 2010, Pall Sigurdsson <palli@opensource.is>
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# About this script
#
# This script monitors a specified Media pool of HP Dataprotector
# Issues a warning if free media in $pool are less than $warning
POOL="$1"
WARNING=5
CRITICAL=2
if [ "$POOL" = "" ]; then
echo "Unknown - No Media pool specified"
exit 3
fi
OUTPUT=$(/opt/omni/bin/omnimm -list_pool "$POOL")
RESULT=$?
if [ $RESULT -eq 3 ]; then
echo "Unknown - Media pool '$POOL' was not found"
exit 3
fi
if [ $RESULT -ne 0 ]; then
echo "Unknown - exit code from omnimm=$RESULT, output: $OUTPUT"
exit 3
fi
FREE_MEDIA=$(echo "$OUTPUT" | tail -n +4 | wc -l)
PERFDATA="'$POOL'=$FREE_MEDIA"
if [ $FREE_MEDIA -lt $CRITICAL ]; then
echo "Critical: $FREE_MEDIA available media in pool $POOL | $PERFDATA"
exit 2
fi
if [ $FREE_MEDIA -lt $WARNING ]; then
echo "Warning: $FREE_MEDIA available media in pool $POOL | $PERFDATA"
exit 1
fi
echo "OK: $FREE_MEDIA available media in pool $POOL | $PERFDATA"
exit 0